1

I would like to track external click event on my website. I tried to follow a lot of tutorials but its seems this is never what I want to do.

In the source code there is:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-00000000-1']);
_gaq.push(['_setDomainName', 'mydomain.com']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script');
    ga.type = 'text/javascript';
    ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);

Is that enough to track the click event?

Then should I write:

<a href="myLink" target="_blank" onClick="_gaq.push(['_trackEvent','partner link', 'Click']);">
    hello
</a>

to get event tracking on that link?

duncan
  • 31,401
  • 13
  • 78
  • 99
ramsey_lewis
  • 558
  • 8
  • 25
  • 1
    yes, probably. Have you tried it? – duncan May 29 '15 at 08:37
  • mind that tracked click events sometimes don't show immediately in your GA admin. Open your dev tools, go to the networks pane and see if any event is sent from the browser after clicking on your target. – Aurelio May 29 '15 at 08:41
  • no it doesn't work. I went in GA goals, but there is nothing. i tried this one : `Google’s Guide to Event Tracking` but it doesnt work neither. I don't know if im doing wrong in the code or in GA pannel – ramsey_lewis May 29 '15 at 08:58
  • Just to be certain, are you using classic GA or Universal Analytics? – nyuen May 29 '15 at 13:02
  • Just to be sure, you have changed the code so it includes your domain and UA number, right? And in case you were not aware, no GA data will appear right away in the GA normal reports, but should be something in the Real time reports. Best though is to use the GA Debugger Chrome extension to see if the GA hit event is sent - you should be able to see it in the console. – MarkeD May 29 '15 at 18:24
  • Yes i use the GA number provided by my GA account, i already went i "real time reports". i'll keep digging , thanks – ramsey_lewis May 30 '15 at 17:52

0 Answers0