the google analytics help section tells me it's possible to track javascript events using the _trackPageview() function. (you can see more here: http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55521.
i've tried this, but it's not working. i think it has something to do with the _trackPageview function being defined at the bottom of the page, and not the top.
any ideas?
thanks!
debra
Comments
Comment #1
hass commentedNo. For links you do not need to do anything.
Comment #2
debonator commentedhmm... it's not showing up anywhere in google under events, and i've checked everywhere. in fact, it's never shown up, not even before google changed the API.
Comment #3
debonator commentedoh, i should probably also explain that it's not a link to a page, per se. it's a link to the rock the vote registration widget that let's you register to vote. the widget itself is hosted at rock the vote (and not on my side). could that be part of the problem?
thanks.
Comment #4
hass commentedWith this explanation and without the urls showing the issue I cannot repro/help. http://drupal.org/node/73179
Comment #5
debonator commentedsorry for the delay. steps to reproduce
1. go to www.longdistancevoter.org/california
2. under voter registration, choose the recommended method (our voter registration widget)
3. clicking that link *should* show up as a google analytics event, but does not.
it's driving me slightly crazy, since clicks on our voter registration widget are one of our primary metrics.
thanks in advance for your help.
debra
Comment #6
hass commentedI cannot solve such ultra special click events in the module, but you could extend your page code yourself. Please try to append
pageTracker._trackEvent('Registration', 'Click', 'Voter Registration Widget');to your click event. This is an example how you could name your event... change the naming how you like it.Comment #7
debonator commentedthank you so much. i'll try that out and see what happens!
Comment #8
debonator commentedone last question: do i just need to add
pageTracker._trackEvent('Registration', 'Click', 'Voter Registration Widget');"or is it
onClick="pageTracker._trackEvent('Registration', 'Click', 'Voter Registration Widget');thanks again for your help!
debra
Comment #9
hass commentedNot tested, but I think it should be something like
... onclick="javascript:pageTracker._trackEvent('Registration', 'Click', 'Voter Registration Widget');" ...Comment #10
BradleyT commentedIt's not an issue with this module, I've been using both (well 5.x) for a long time.
I use this a lot when there's an image and a text link that both link to the same destination page. Put the code on both links and easily track which one gets clicked more often.
<a href="/sign-up" onclick="javascript:pageTracker._trackPageview('/sign-up/banner/83');"><img src="banner83.gif" alt="banner 83" border="0" /></a><a href="/sign-up" onclick="javascript:pageTracker._trackPageview('/sign-up/text/click-here-to-sign-up');">Click Here to Sign Up</a>Also great for tracking clicks on PDF files.
Also note the lowercase onclick so you don't get validation errors :)
Comment #11
frobThis is not an issue for this module, however, I wrote a module that allows tracking based on css class selectors that integrates with the google analytics module. It is aptly name Google Analytics Event Tracking.
It deploys a simple php api to allow tracking of javascript events through google analytic's event tracking api. This mean no more ugly custom javascript to do event tracking.