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

  • Home
  • SEARCH
  • 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 8406953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:15:19+00:00 2026-06-09T23:15:19+00:00

I am using custom variables in my javascript that is accessible to all the

  • 0

I am using custom variables in my javascript that is accessible to all the pages and below is my GA tracking code immediately preceding the closing head tag in the only page called index.html.

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-33766550-1']);
        var currentCountry = 'N/A';
        if (localStorage.getItem('country')) {
            currentCountry = localStorage.getItem('country');
        }
        _gaq.push(['_setCustomVar', 1, 'Country', currentCountry]);
        _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);
        })();

The GA tracking is working fine for me.
I have so far been able to track only one custom variable that has been defined in the main tracking code in the head section called country(as shown above).

The rest of the custom variables that I have used in the javascript file(this js is always accessible in index.html) seems to be not getting called at all. This js file contains the different _gaq.push commands for the different custom variables, as shown below.

_gaq.push([‘_setCustomVar’, 5, ‘Page’, ‘app/index.html#portfolioDetailPage’]);

Question: Why am I not been able to track these custom variables in the GA unlike the ‘country’ custom variable I passed in the main tracking code?
Do i need to pass _gaq.push([‘_trackPageview’]) after each of the _gaq.push for custom variables declarations?

Can anybody please suggest, I am in a big mess 🙁

Thanks

  • 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-09T23:15:20+00:00Added an answer on June 9, 2026 at 11:15 pm

    Thanks Eduardo. I might of typed it wrong I am actually using the correct code. I was using custom variables for tracking whereas in my scenario event tracking made more sense.

    if(_gaq) _gaq.push([‘_trackEvent’, ‘Page’, ‘Home_Page_Landing’, ‘app/index.html’]);

    Thanks

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

Sidebar

Related Questions

Setup I am using custom Forms Authentication - all standard stuff. In the Login
I'm using custom class that subclass from UILabel. It works fine unless I change
I'm using custom renderer on JList, but none of components rendered are accessible. list.setCellRenderer(new
I am using the async version of Google Analytics along with custom variables and
How to use custom variables when using twitter-bootstrap-rails gem? I want to change the
I have created a simple code editor using Angular JS & old fashioned JavaScript
Using Goggle Analytics I'd like to use a custom variable. This is built in
When using custom assemblies in a visual studio project. How does one check in
I'm aware of using custom configuration values for my custom services, but what if
i am using custom checkbox buttons in my table view and want to save

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.