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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:24:00+00:00 2026-05-28T21:24:00+00:00

I want to push a javascript variable into an array. Specifically, I want to

  • 0

I want to push a javascript variable into an array. Specifically, I want to push a Google Analytics account ID (UA-XXXXXXXX-X) into the Google Analytics javascript tracking code in the footer of my site.

(function($) {

        var jsvars = {"columns":"1","mobilemenu":"1","googleanalytics":"UA-XXXXXXXX-X"};
        var googleanalytics = jsvars.googleanalytics;

        /* hit run to to confirm the googleanalytics variable is available */
        alert (googleanalytics);

        var _gaq = _gaq || [];
        /* I want to push the googleanalytics variable into the array */
        /* When I view source, it does not show as UA-XXXXXXXX-X, it just shows as googleanalytics */
        _gaq.push(['_setAccount', googleanalytics]);
        _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);
        })();

})(jQuery);

http://jsfiddle.net/robflate/2MnM7/

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-05-28T21:24:00+00:00Added an answer on May 28, 2026 at 9:24 pm

    Extending Pointy’s comment to an answer, you can’t use your browser’s “view source” function to see what you’re looking for. “View Source” will show the JavaScript as you wrote it. It won’t show you what any of the values are at runtime, etc. For this, you’ll want a decent JavaScript debugger – now built-in to all major web browsers. (Or use Firebug for Firefox.)

    If you set a debugger breakpoint on this line, you’ll be able to see that googleanalytics is UA-XXXXXXXX-X. This is similar to what you already demonstrated yourself with your alert line.

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

Sidebar

Related Questions

I have a JavaScript array dataArray which I want to push into a new
I am having a JavaScript array and I want to convert this array into
I've got the google analytics javascript and I want to make it smaller. But
I've been looking to use Google Analytics _gaq.push() function on a single-page JavaScript application
I have a JavaScript code that I want to bring the idea into my
The javascript code is attached below. Two push pins are added to a Bing
I have a string in a variable: var test= http://www.gmail.com@%@http://www.google.com@%@http://www.yahoo.com@%@; I want to split
I want to push a button programatically in javascript, just once, by pasting javascript
TL;DR version: I want to avoid adding duplicate Javascript objects to an array of
Here is a snippet of my JavaScript Code that I want to DRY up:

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.