Manual link tagging

jumpfightgo - June 2, 2009 - 21:04
Project:Google Analytics
Version:6.x-2.2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I'd like to be able to track clicks on a links in a block. One block is just a big button in the sidebar, and appears on several pages. Currently there is no way to piece out how may people clicked on that button.

Google suggests using their link builder to manually tag links.

The link builder doesn't work with drupal though, at least I haven't been able to get it to work. I suspect because drupal uses javascript to write the analytics variables?

Is there a way to manually add the link tracking - either to a single link with HTML or through a javascript snippet?

#1

hass - June 3, 2009 - 06:20
Category:feature request» support request

#2

hass - June 3, 2009 - 06:24
Status:active» fixed

Add an onclick event to your block button and give this click a name. See the GA docs about the possible ways - there is more than one for e.g. Event tracking, Campaign, others

#3

jumpfightgo - June 9, 2009 - 16:06

Thanks!!!

Here's what I ended up doing; hope it's helpful to someone:

For the banner block at the top of our homepage we wanted to track how many people clicked through to a landing page on our site and how many people collapsed the block (there's a "hide this" link").

To track click-throughs I added an onClick javascript call based on the examples at http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

<?php
$block
['content'] = <a href="http://harvardmagazine.com/commencement-2009" onClick="pageTracker._trackEvent(\'Block - Homepage Flyover\', \'Click-Through\', \'http://harvardmagazine.com/commencement-2009\');">;
?>

For the "hide this" link, I added a similar OnClick call:

<?php
$block
['content'] = <a href="#" onClick="pageTracker._trackEvent(\'Block - Homepage Flyover\', \'Hide\');" class="toggle headline">;
?>

AttachmentSize
block-flyover-sample.png 84.07 KB

#4

System Message - June 23, 2009 - 16:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.