Forum Moderators: DixonJones

Message Too Old, No Replies

Google Analytics - does the tracking code work in include file?

         

teylyn

2:51 am on Dec 20, 2005 (gmt 0)

10+ Year Member



I'm one of those who got on the bandwagon early and I get statistics from Google Analytics just fine. I'm now redesigning my website and would like to avoid getting all those hits while I'm testing pages. I know I can suppress the IP range from whither I hail, but is it possible to put the tracking code into a javascript file that is included in the header? Anybody tried that yet?

If I'm not making myself clear: the code in each and every html page header is something like

<script type="text/javascript">
_uacct = "UA-XXXXX-1";
urchinTracker();
</script>

If I create a file gacode.js with the content
_uacct = "UA-XXXXX-1";
urchinTracker();

and put the line
<script type="text/javascript" src="gacode.js"></script>

in the header, would that work, too? If so, I could just comment out the tracking code in one place and go ahead with testing my redesign.

I don't want to suppress hits from our own IP range because we run other tests on GA as well.

cheers

teylyn

bill

5:53 am on Dec 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've put the Analytics tracking code in an external file on one site and the tracking seems to be working fine. The only error I'm seeing is the section of the reports where it checks to see whether you have the Analytics tracking code installed properly on your site. In my case it says it's not...but I see this is a problem in the FAQ as well, so I don't know if it's just me.