Custom Tracking with Google Analytics

2019-05-31 23:56发布

I am trying to figure out how to use my google analytics account, and do custom tracking on certain links and such, but following the technical information on the help site on google isn't getting me anywhere. Has anyone done something like this? Point me in the right direction.

UPDATE This is the code, I am not seeing the results in my analytics account yet, but I am not getting errors now.

In header:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX']); //Commented Out for posting
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
  })();

</script>

THen on the href of my link I put this:

onclick="_gaq.push(['_trackEvent', 'Link Sponsored', 'Clicked Sponsored']);"

Is this the Correct Way to do it via asyc ga code?

1条回答
SAY GOODBYE
2楼-- · 2019-06-01 00:32

I can't find the problem from your code.

A couple of things:

  1. have you enabled "Event Tracking"? This must be set in your "Profile"

  2. While watching HTTP header activity using, for instance, the Firefox add-on "Live HTTP Headers", look for requests to the _utm.gif. To do this:

    • open the LiveHTTP Headers Panel;

    • then select the "Config" tab;

    • then check "Filter URLs with regexp;

    • type _utm.gif in the text box next to the box you just chekecked; and

    • select the "Generator" tab to record the activity.

查看更多
登录 后发表回答