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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:05:41+00:00 2026-06-10T10:05:41+00:00

I know Google clearly recommends calling analytics inline in the head. However are there

  • 0

I know Google clearly recommends calling analytics inline in the head. However are there any potential pitfalls of calling it in a external file?

I have installed the Google Analytics Debugger for chrome and everything appears normal. I am calling it in an external js file in the head of the page.

  • 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-10T10:05:42+00:00Added an answer on June 10, 2026 at 10:05 am

    This isn’t exactly what Google suggests.

    Basically, you can instantiate GA as early as possible — that’s the part that says:

    var _gaq = _gaq || [];
    

    The rest of it, you can load at the bottom of the page.

    You can even put the _gaq =...; in an external file at the top of the page, and then the rest of it at the bottom.

    The goal is this:

    Google makes _gaq an array at the beginning. Then you use the array’s .push(...); method to add tracking to the array (really, you’re just adding arrays of strings).

    When you add the second part of the code, at the bottom of the page, it’s saving the data that’s inside of the _gaq array, to a holding array. Then it’s turning _gaq into a real-live program, where .push(...); from now on, on the page, actually sends data and whatnot.

    And on initial-load of the full file, _gaq will run through the array of pushed instructions and turn that into a server-call.

    They suggest starting _gaq as high on the page as possible, so that you can add user-based tracking to the page, or to buttons, or whatever… …so that when the program finally does load at the bottom of the page, all of those actions that you’ve added via _gaq.push(["_method", "data"]); will be tracked by GA, when it’s running, so you don’t miss any events.

    Now, you don’t want to put both the _gaq =... part of the code, AND the script-download part of the code at the top of the page. Downloading scripts takes a while.
    GA is doing it the right way, and is loading it asynchronously, which is perfect… …but you can still clean it up by moving the second half to the bottom of your page (or putting it in an external script).

    So the answer ends up being, yes, feel 100% free to move the GA code into external scripts, that’s not going to change a single thing about how it runs.

    But you should still consider leaving the external script for _gaq=... at the top (so that if you’re tracking user-behaviour to custom events, you can do that as soon as the page is ready — but then why put that in an external script, when it will take time to load and execute, versus the actually assignment, which will take microseconds, even on slow browsers?).

    And then move the script call down the page (or move it into an external file, which is referenced at the bottom of your page).

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

Sidebar

Related Questions

Does anyone know how Google Analytics exports their PDFs? They don't seem to make
Does anybody know what google web master tools offer I have google analytics on
Perhaps, you know that google image search by local image file .. But, Google
Don't know how to google for such, but is there a way to query
I know there have been a lot of questions of this, however those were
I do know about the two previous posts: PHP Google Drive API - File
I'm wanting to use a plugin know as dropdown-check-list: http://code.google.com/p/dropdown-check-list/ However, some of its
Want know any external API web service or PHP libraries that will allow me
I know a single file assembly consists of Manifest + IL + Resources. There
I know that google's v8 compiles javascript into native machine (binary if I understand

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.