CornerPixel Blog RSS 2.0

# Friday, September 05, 2008

I am getting to the stage where I want to implement Google Analytics and see just how much traffic I am getting on my new website.  I went to Google Analytics and started my account and started the process of getting my script to add to my site.

At this point I was thinking about having to make different profiles for each of my subdomains.  I thought about it and I didn't like that idea.  I would end up getting referrals from my own domains, and that would mess up my stats a fair bit.

Well I did what I always do when posed with an issue I am not sure how to solve.  I went to Google and did a search.  I came up with a very good site and post to help me through.  I found that I just had to add one line of script to my Google Analytics code and all would be good.

<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-XXXXXX-X");
pageTracker._setDomainName("domain.com");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Notice the part of the code in bold.  pageTracker._setDomainName("domain.com");

Just change out the domain.com to match your domain and you are good to go.  Above is the simple solution, but for a very cool explanation go to the Google Analytics "Unofficial" Blog.

Friday, September 05, 2008 6:35:37 PM (Pacific Standard Time, UTC-08:00)

#       Comments [0] - Trackback

Code

Comments are closed.

Archive

<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Email Subscription

Sign up to get the CornerPixel Blog delivered to your email.

About the Author

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Sign In

Statistics

Total Posts: 52
This Year: 3
This Month: 0
This Week: 0
Comments: 28