Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Tips And Tricks How To Track Website With Multiple Google Analytisc Accounts

How To Track Website With Multiple Google Analytisc Accounts

I work for a world wide digital agency and I build a lot of websites or campaigns for my clients. I always create a new Google Analytics account for every website/campaign which is used internally by my company to generate traffic (visitors, pageview, etc) and goals report.

As you may know, setting up a Google Analytics tracking code on your website is pretty easy as you just need to copy & paste the code from Google and place it somewhere (above </body> tag) of your website. However, if client also want to track their site by themselves, the process is a little bit complex because you have to track in parallels. It means you need to setup multiple Google Analytics tracking codes on your website.

Below is a piece of code I usually use to track 2 GA tracking codes in my web pages:

<script type="text/javascript"> 
 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-Y']);
  _gaq.push(['_trackPageview']);
 
  _gaq.push(['_setAccount', 'UA-XXXXXXXX-YY']);
  _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>

<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXX-Y']); _gaq.push(['_trackPageview']); _gaq.push(['_setAccount', 'UA-XXXXXXXX-YY']); _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>

And a function use to track events or custom function calling within Flash or Ajax:

<script type="text/javascript"> 
 
	function trackGAPageView(s)
	{
		_gaq.push(['_setAccount', 'UA-XXXXXX-Y']);
		_gaq.push(['_trackPageview', "/" + s]);
 
		_gaq.push(['_setAccount', 'UA-XXXXXXXX-YY']);
		_gaq.push(['_trackPageview', "/" + s]);
	}
 
</script>

<script type="text/javascript"> function trackGAPageView(s) { _gaq.push(['_setAccount', 'UA-XXXXXX-Y']); _gaq.push(['_trackPageview', "/" + s]); _gaq.push(['_setAccount', 'UA-XXXXXXXX-YY']); _gaq.push(['_trackPageview', "/" + s]); } </script>

Note: please update UA-XXXXXX-Y and UA-XXXXXXXX-YY with your real Google Analytics tracking code.

Sep 13, 2011Hoan Huynh
Facebook Publish To Wall With Popup Or Dialog And Call BackHow To Check A Port Is Open Or Blocked In Windows
You Might Also Like:
  • How To Tracking Click Event With Google Analytics
  • How To Add User To Your Google Analytics Report
  • Export Google Analytics Report To PDF In New Version
  • PHP Google Analytics API Examples
  • How To Export Google Analytics Report To PDF Or XML
  • Facebook Publish To Wall With External Link And Track Callback
  • Build search box for my website at Google.com
  • How To Send Google Analytics Report To Emails
  • Top Free Real Time Website Analytics Services And Tools
  • What Google Factors Will Tell You about Negative Signals of Your Website
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

9 years ago Tips And TricksGoogle, Google Analytics173
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
21,946 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
19,784 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,616 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,126 views
C# Read Json From URL And Parse/Deserialize Json
9,583 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • How to Write a Research Paper For Sale
  • Essay Writing – Some Useful Suggestions for Writing Urgent Essays
  • Essay Writing Service Tips For The Online Essay
  • Research Paper Writing Service
  • Annotated Bibliography Example – How it Can Help You
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (66)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development