Forum Moderators: DixonJones

Message Too Old, No Replies

Two Google Analytics Code on one page

Implementing two Google Analytics Code on one page

         

Mercy_Livi

7:32 am on Sep 23, 2009 (gmt 0)

10+ Year Member



Hello,

I would like to track my domain.com and domain.com/directory with two separate Google analytic tracking code. I am about to implement the following code.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-123456-1");
pageTracker._initData();
pageTracker._trackPageview();
var pageTracker2 = _gat._getTracker("UA-123456-2");
pageTracker2._initData();
pageTracker2._trackPageview();
</script>

>> Is it a right way to implement? If so, please advice where these code need to installed. Only in all pages in Sub directory / Domain + Sub Directory.

Greatly appreciate the help.

Thank you!

SanDiego Art

5:11 pm on Sep 23, 2009 (gmt 0)

10+ Year Member



Why not put 1 tag on all the pages, and the second tag only in the /directory?

That way profile 1 has all page data, and profile 2 just the /directory data.

Actually I don't think you even need separate code for this. Can't you just setup a new profile in GA using a filter? It looks like you are using GA code from the same account... So you should just be able to setup a filter on /directory and it will have its own profile in GA.

cotine

2:09 am on Sep 25, 2009 (gmt 0)

10+ Year Member



hi Mercy_Livi

you could use a new profile to creat a exclude the directory filt to do this, i think if you have used a new profile with filter ,you will feel ga is amazing