Monday, December 4, 2023
rated 0 times [  193] [ 1]  / answers: 1 / hits: 31888  / 15 Years ago, wed, july 15, 2009, 12:00:00
var gaJsHost = ((https: == document.location.protocol) ? https://ssl. : http://www.);
document.write(unescape(%3Cscript src=' + gaJsHost +' type='text/javascript'%3E%3C/script%3E));

var pageTracker = _gat._getTracker(UA-XXXXXXX-1);
catch(err) {}

Would it be possible to call this script from an external JS file? I wanted to to something like:

<script type=text/javascript src=googleanalytics.js ></script>

and put one of these on each of my HTML pages.

The code I have above will be inside googleanalytics.js

Google's instructions was to put the code in each page. The problem with that is it makes it harder to change the tracking code. (We use different tracking codes for our DEV and PROD pages).

I've tried it out and it doesn't seem to be working.

Is there something wrong with doing that? Or is there something else causing the problem?

Important FYI
Please note that we are using IE6 and 8 browsers (yes, I know, no need to tell me)

More From » google-analytics


Yes this is possible. If it is not working then there is something else going on.

Just a thought, Google Analytics is usually about a day behind in reporting so when you make changes it will take some time before you know it is working. What I like to do is hit a page that does not get traffic very often to assure me that I have my tracking set up correctly.

Also, you might try making the link an absolute link in your <script tag. It might just be looking in the wrong place for the analytics code.

[#99121] Friday, July 10, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 441
Total Questions: 105
Total Answers: 106

Location: Christmas Island
Member since Sun, Mar 7, 2021
3 Years ago