Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6603365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:59:58+00:00 2026-05-25T18:59:58+00:00

I am struggling to get google analytics to track navigation using anchor tags. I’ve

  • 0

I am struggling to get google analytics to track navigation using anchor tags. I’ve read that all I need to do is include:

  _gaq.push(['_setAllowAnchor', true]);

However this is still not working. I have a 1 page website which uses javascript (jquery) and anchor tags for navigation. When I examine my analytics report all I see is that a user (only me for my website so far) loaded index.html and reloaded it several times, rather than navigated to a specific anchor. My analytics script is below, and is included in the head section. As I say, the script works it just doesn’t track anchor navigation. Are there any work arounds or errors in my script?

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'XXXXXXXXXXX']);
  _gaq.push(['_setAllowAnchor', true]);
  _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';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:59:59+00:00Added an answer on May 25, 2026 at 6:59 pm

    Whatever you read about _setAllowAnchor is mistaken.

    _setAllowAnchordocs is not a feature that enables anchor-aware navigation (or, onhashchange) tracking. Instead, its for detecting campaign tags in the URL’s anchor, so that

    http://google.com/#foo&utm_campaign=bar

    gets tracked in Google Analytics with “Campaign” set to bar.

    Or, as the documentation puts it:

    This method sets the # sign as the query string delimiter in campaign tracking. This option is set to false by default.

    However, by default, that URL value will still only be tracked in Google Analytics as “/”, since the default method that Google Analytics tracks pageviews is location.pathname+location.search.

    Alternatives

    To allow for tracking of your internal anchors, you just need to just add a _trackPageview call, with a custom pageview value, into where ever you’re detecting or changing the URL’s anchor, so that it runs any time you’re changing the ‘page’ or the ‘anchor’

    Basically, that just means adding this line:

    _gaq.push(["_trackPageview", new_url]);
    

    where new_url is the URL you’d like to be tracked.

    Really, you could just defined new_url as:

    var new_url = location.pathname+location.search+location.hash
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to get Google Analytics data using OAuth? I'm struggling with it
I'm trying to make some text bold using HTML, but I'm struggling to get
I've been struggling with queries with Google's datastore and wanted to get some help.
I've been struggling all morning to get PIL installed on Cygwin. The errors I
I am trying to get Oauth working with the Google API using Python. I
I'm struggling to get Windows Live Web Authentication running on Google App Engine (GAE)
I'm really struggling to get my first AXIS SOAP client to work. I'm using
I'm struggling trying to cluster 50 markers using the markerclusterer v3 with Google maps
I am using garb gem to fetch the data from the google analytics and
I'm struggling to get around the 404 errors from asp.net mvc beta when deploying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.