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 8355617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:55:13+00:00 2026-06-09T09:55:13+00:00

I have basic single page website with the normal Google Analytic code: var _gaq

  • 0

I have basic single page website with the normal Google Analytic code:

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-##-##']);
  _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);
  })();

However my links are like bookmarks – they basically slidedown the single page. My links when clicked are essentially pages but within the same template – they slide to reveal elements of content.

<a href="#section-3">about us</a>

Is there a way I can update the Analytics tracker or somehow track links? So in Analytics I will see people spent so much time on a page etc.

  • 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-06-09T09:55:14+00:00Added an answer on June 9, 2026 at 9:55 am

    Use jQuery for this.

    Have the Analytics in your head, notice cleaner code:

    <script>
        var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
        (function(d, t) {
        var g = d.createElement(t),
        s = d.getElementsByTagName(t)[0];
        g.src = '//www.google-analytics.com/ga.js';
        s.parentNode.insertBefore(g, s);
        }(document, 'script'));
    </script>
    

    And now place this in your footer where #main-navigation is an example of your UL > LI menu list. It will track all those pages.

    jQuery(function($){
            $("#main-navigation a[href*='#']").on("click", function(){
                var $url = $(this)
            _gaq.push(['_trackPageview', $url.attr('href')]);
            console.log('_trackPageview', $url.attr('href'));
        });
    });
    

    Also note that; My code using protocol and cleaner JavaScript is up to 2000x faster.
    http://jsperf.com/protocol-check-vs-hardcoded-string reference further http://mathiasbynens.be/notes/async-analytics-snippet

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very basic ASP.NET web site. It has a single page (TestPage.aspx)
I have a single-page scrolling website. It uses a fixed-position nav bar with jquery
A very basic question... I have a jquery function that fires on page load:
I have some basic jquery code sitting in the header of the header file
I have 5 single page tiff images. I want to combine all these 5
I have some basic pageview incrementing code set up on a LAMP server (see
I have a highly dynamic single page interface where various user events trigger new
Kind of a basic question, but I have a page similar to this example:
I'm writing a little single page app (using knockout.js :-)) whereby i have a
I have a basic WinRT XAML UserControl with a single dependency property as implemented

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.