Hello David,
I'm currently putting all my effort to set up the Google event tracking via a server side implementation cause i don't want to rely on clients wish to use JS or not.
Straight to the point. I found some useful code snippets to do that:
{code saved}
Both solutions work by requiring the necessary class and then fire/send the event in google analytics.
I attempted re-write the jump.php like this but it doesn't forward the visitor to products buy_url nor the event is tracked.
{code saved}
Ideally i would like to pass as the event Category the variable $product["merchant"] and as event Label the variable $product["original_name"]. Could you please point me to the right direction? Do you propose a different approach?
Thank you
Panos
Hello David,
that did the trick ! Clicks are now being tracked as GA events, thanks so much !!
BR
Panos
Hello Panos,
There was a syntax error in your modifications to jump.php that you posted - this line;
$ssga->send()
...is missing the semi-colon.
You might still however wish to use this following the database query (as you had commented out), but changing the SELECT list of just filename,buy_url to * (all fields) so that you can pass product details through to the tracking, e.g.
<?php
require("includes/common.php");
include("includes/ss-ga.class.php");
$sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";
if (database_querySelect($sql,$rows))
{
$product = $rows[0];
$ssga = new ssga( 'UA-MY-GA-ID-1', 'mydomain.xx' );
$ssga->set_event( 'Event', 'Categories', 'Label', 'Value');
$ssga->send();
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE filename = '".database_safe($product["filename"])."'";
database_queryModify($sql,$insertID);
header("Location: ".$product["buy_url"]);
}
exit();
?>
With the tracking code in this position, you could then use $product["category"] etc.
Hope this helps!
Cheers,
David.
--
PriceTapestry.com