Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have searched for how to track anchor links in analytics, but couldn't get it working. I have this code in the header:

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('_setAllowAnchor', true);
ga('create', 'UA-*******-1', '****.com');
ga('send', 'pageview');

And my links looks like this:

<a href='#/contact'><span>Contact</span></a>

I also tried to use this links:

<a href='#/contact' onClick="_gaq.push(['_trackPageview', location.pathname+location.search+location.hash]);"><span>Contact</span></a>
share|improve this question

migrated from stackoverflow.com Oct 10 '13 at 19:53

This question came from our site for professional and enthusiast programmers.

This code must work:

<a href="#contact" onclick="_gaq.push(['_trackPageview' ,'/contact/']);"><span>Contact</span></a>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.