I’ve got a WP3 custom menu, with a custom link in the menu, How can I add google analytics event tracking to that custom link.
Thanks
Alex
I’ve got a WP3 custom menu, with a custom link in the menu, How can I add google analytics event tracking to that custom link.
Thanks
Alex
You must be logged in to post a comment.
Is it an outbound link? Otherwise it should automatically get tracked (as a page view). If it is outbound, I’d set a class on the custom menu item in WordPress (using the CSS Classes (optional) field). Then you could trigger that link with JavaScript. For example, with jQuery you could do something like this (assuming you are using the Async version of Google Analytics):
The setTimeout is there to make sure that Google Analytics has time to read the event before the browser sends the user to the outbound link.
I hope that helps.
Link:
http://www.google.com/support/analytics/bin/answer.py?answer=55527