twistedtrick
Power Member
- Aug 21, 2009
- 674
- 395
Right now I am working with a client who wants to track outbound clicks on their sponsor logos.
In the footer of the website, I am able to manually add the tracking code to each link without any issue. However, on the sidebar of the site the client wanted to rotate the logos so we went with NextGen Gallery to handle the image rotation, and then modified the code a little so that the gallery widget thumbnails could be hyperlinked to an external URL instead of just the image itself.
I believe I just have an issue with the PHP syntax because I am not a programmer at all. Any help would be greatly appreciated!
Here is the working code, that is NOT tracking Analytics Clicks:
Here is my attempt at adding Event Tracking to this code, but I receive syntax errors I believe due to my improper usage of single, double quotes and escape characters. My goal is to place each link in the "outbound-widget-sponsor" Event Category in Google Analytics, and give the Event Action as the URL (with the . $image->alttext . variable).
In the footer of the website, I am able to manually add the tracking code to each link without any issue. However, on the sidebar of the site the client wanted to rotate the logos so we went with NextGen Gallery to handle the image rotation, and then modified the code a little so that the gallery widget thumbnails could be hyperlinked to an external URL instead of just the image itself.
I believe I just have an issue with the PHP syntax because I am not a programmer at all. Any help would be greatly appreciated!
Here is the working code, that is NOT tracking Analytics Clicks:
Code:
$out = '<a href="' . $image->alttext . '" title="' . $description . '" ' . $thumbcode .'>';
Here is my attempt at adding Event Tracking to this code, but I receive syntax errors I believe due to my improper usage of single, double quotes and escape characters. My goal is to place each link in the "outbound-widget-sponsor" Event Category in Google Analytics, and give the Event Action as the URL (with the . $image->alttext . variable).
Code:
$out = '<a href="' . $image->alttext . 'onclick="javascript:_gaq.push([\'_trackEvent\',\'outbound-widget-sponsor\',\'' . $image->alttext . '\'''" title="' . $description . '" ' . $thumbcode .'>';