I want to use Google Analytics to track clicks on an outbound link in my Milonic Menu. I need to add the following code to the url:
<a onclick="_gaq.push(['_trackEvent', 'Outbound Links', 'Click', 'Google']);"
How do I do this without breaking the menu?
Adding onclick event to links
Re: Adding onclick event to links
Hi,
I am not a js person, nor analytics so I will post to Milonic, however, I did find a couple of post about onlclicks in a link and using it in a menu. Here is the response, but I have no idea if it will work, you would have to try it and see if the google analytics actually does the tracking or whatever. The original link code given as an example was
the original aI menu code was
and then the onclick event was put in like this
Andy said to remove the javascript: part and make the aI the following:
So, using yours, and not knowing anything about the text or url, I made this up
However, please note, the one Andy put in did not have those square brackets, and it also had a repeat of the url, i.e. that /forms/helmet_rule.doc stuff so I'm not really sure if this will do anything, but figured you could play and see if it worked while I post to Milonic . I have no way to test for google analytics on my computer to try anything out for you.
Ruth
I am not a js person, nor analytics so I will post to Milonic, however, I did find a couple of post about onlclicks in a link and using it in a menu. Here is the response, but I have no idea if it will work, you would have to try it and see if the google analytics actually does the tracking or whatever. The original link code given as an example was
Code: Select all
<a href="http://websites.milonic.com/example.com" onClick="javascript: pageTracker._trackPageview('/outgoing/example.com');">
Code: Select all
aI("text=New Helmet Rule;url=/forms/helmet_rule.doc;status=New Helmet Rule;separatorsize=1;");
Code: Select all
aI("text=New Helmet Rule;url=/forms/helmet_rule.doc;clickfunction=javascript: pageTracker._trackPageview('/forms/helmet_rule.doc') status=New Helmet Rule;separatorsize=1;");
Code: Select all
aI("text=New Helmet Rule;url=/forms/helmet_rule.doc;clickfunction=pageTracker._trackPageview('/forms/helmet_rule.doc');separatorsize=1;");
Code: Select all
aI("text=Whatever Text;url=someplace/on/the/web;clickfunction=_gaq.push(['_trackEvent', 'Outbound Links', 'Click', 'Google']);" );
Ruth
Re: Adding onclick event to links
Thank you! I"ll give that a try.