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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:29:17+00:00 2026-05-23T18:29:17+00:00

I was playing around with custom variables in Google Analytics and wasn’t sure why

  • 0

I was playing around with custom variables in Google Analytics and wasn’t sure why the following actually works. Why does Google’s tracking code get executed first, especially since it is at the bottom of the page?

Both scripts are in self-executing functions, so how does javascript determine which one to execute first?

 // top of the page
  <script type="text/javascript">
              $(function ()
              {
                    _gaq.push(['_setCustomVar', 1, 'Account', 'PartTime', 1]);
              });
        </script> 


// bottom of the page
        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-xxxxxxxxxx']);
            _gaq.push(['_setDomainName', '.xxxxxxxx.com']);
            _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-23T18:29:18+00:00Added an answer on May 23, 2026 at 6:29 pm

    The first one does execute first, and isn’t in a self executing function.

    It consists of a call to the $ function and has one argument: an anonymous function.

    $ is a very badly named function. The name itself is meaningless and it has been adopted by half a dozen different libraries to do half a dozen different things.

    In jQuery, if you pass a function to $ it runs that function when the ready event is triggered (but the end of the HTML document being parsed). This is probably what is happening here.

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

Sidebar

Related Questions

I'm playing around with a custom theme for Wordpress and I have this code
Just playing around with Wordpress 3.0 for the first time. I've installed the Custom
I been playing around with some custom html helpers and I now I am
When I was playing around with Joomla! source code, I saw such as code
Playing around with Google Maps these days, with some directions. I have a map
i'm playing around with the navigator class and custom views within air for android
I am playing around with the KeyboardFocusManager and my own custom KeyEventDispatcher that redispathes
I've been playing around with Apple's aurioTouch demo which is sample code for their
I'm playing around with 2D drawing within a custom view. So far I've got
I was playing around with how to use the Configuration Manager to read/write custom

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.