Neal Grosskopf Dot Com A NG Designs Site

Neal Grosskopf Dot Com Return To Neal Grosskopf's Home Page a NG Designs Site

Toolbar

  • Skip To
    • Menu
    • Content
  • Validate
    • HTML
    • CSS
    • WAI
  • Font Size
    • Small
    • Medium
    • Large
    • Extra Large
  • Account
    • Create Account
    • Login

Interact

Navigation

  • Home
  • Interact
    • Blog
    • Message Board
    • Open Links
    • Open Videos
    • Photo Gallery
    • Polls
    • Reviews
    • Geek Speak
  • Designs
    • View All Designs
    • Professional
    • Corporate
    • Templates
    • Personal
    • Club
    • NG Designs
    • Web Guides
  • Files
    • Artwork
    • Wallpapers
    • My File Downloads
  • Extras
    • Bookmarklets
    • The Magic 8-Ball
    • Career Builder RSS Feed Generator
    • Monster.com RSS Feed Generator

Tracking Internal Website Campaigns With Google Analytics and PHP

  • Actions
    • View All
    • View Article Statistics
    • View User Statistics
    • Search
    • Subscribe to RSS Feed

Recent Articles:

  • Tracking Outgoing Links in Google Analytics Using Event Tracking and jQuery
  • Tracking Internal Website Campaigns With Google Analytics and PHP
  • Everything You Need to Know About jQuery's .data() Method
  • Google vs. China: How It Will Affect Web Workers
  • Don't Like The New Facebook Home Page? Fix It With 5 Lines of CSS
View All

Subscribe To Feed
loading Subscribers

I'm On Twitter loading

Jul 18

Google Analytics

Internal Campaign Tracking With Google Analytics

Learn how to implement internal website campaign tracking with Google Analytics

Many sites nowdays self promote content deep within from the home page. In many ways this should be considered an internal campaign. On larger websites with multiple stakeholders involved, it becomes even more important to measure how successful internal campaigns are peforming. By default Google Analytics has the ability to track external campaign links pointing to your website, however it does not come with built in functionality to track internal campaigns.

One solution is to use custom variables to track internal campaigns. By using these campaign variables, you can slice and dice your visitor's movement on your website easier. If you're not familiar with campaign link tagging I suggest you click through a couple links in your RSS feeds (Slashdot, specifically uses them) and you'll notice that there are several query strings appended to each link.

Example Tagged Link:

http://science.slashdot.org/story/10/07/14/2222239/The-Chicken-May-Have-Come-Before-the-Egg?from=rss&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Slashdot%2Fslashdot+%28Slashdot%29&utm_content=Google+Reader

Each of these query strings translates into a dimension in Google Analytics. Below is the anatomy of our URL:

&utm_source=feedburner &utm_medium=feed &utm_campaign=Feed%3A+Slashdot%2Fslashdot+%28Slashdot%29 &utm_content=Google

I'm not going to go into too much depth on the built in external campaign tracking for Google Analytics since that's been covered by every blogger in existence already. Google provides an quick and easy form with explanations for each query string value here anyway - http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55578

Using utm_* Query Strings For Internal Campaign Tracking?

NO! Never do this! I suspect many people first consider this when attempting to track internal campaigns but here's why you shouldn't. Each of these query strings is written to a cookie within Google Analytics. If a user searches "Internet Explorer hacks" on Google the following would happen:

utm_source = google.com utm_medium = google / organic If you custom 'tagged' an internal link you'd essentially overwrite the existing utm_source & utm_medium data with your new data thus loosing the original source of the users visit. This is very very bad.

Enough Already, Just Tell Me How To Do This!?!?

Ok, sorry for the long intro but I needed to get that out of the way before moving any further. Instead of using utm_* query strings let's use our own custom query strings, say one that starts with int_

The Following URL:

http://www.yourdomain.com/landingpage/?utm_source=advertiser.com&utm_medium=bannerad&utm_campaign=summerpromotion&utm_content=horizontal

Becomes:

http://www.yourdomain.com/landingpage/?int_source=advertiser.com&int_medium=bannerad&int_campaign=summerpromotion&int_content=horizontal

Hidding Query Strings Within Google Analytics

Next, configure the Google Analytics profile to exclude these new query strings. Otherwise the URLs are going to look different within the reports depending on the refering page and it will render your stats very useless.

  1. Navigate to Analytics Settings > Profile Settings > Edit Profile Information
  2. Under 'Exclude URL Query Parameters:' include the following query strings int_source, int_campaign, int_medium, int_content (or your own)
Hidding Query Strings Within Google Analytics

Configuring Your Google Analytics Tracking Code For Internal Campaigns

Finally, you'll need to slightly modify your tracking code to send these custom variables to Google. This uses Google's pageTracker._setCustomVar function. The names (i.e. Internal%20Campaign) can be named to whatever you like.

<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"); <?php if(isset($_GET["int_campaign"])) echo 'pageTracker._setCustomVar(1,"Internal%20Campaign","'.$_GET["int_campaign"].'",1);'; if(isset($_GET["int_source"])) echo 'pageTracker._setCustomVar(2,"Internal%20Source","'.$_GET["int_source"].'",1);'; if(isset($_GET["int_medium"])) echo 'pageTracker._setCustomVar(3,"Internal%20Medium","'.$_GET["int_medium"].'",1);'; if(isset($_GET["int_content"])) echo 'pageTracker._setCustomVar(4,"Internal%20Content","'.$_GET["int_content"].'",1);'; ?> pageTracker._initData(); pageTracker._trackPageview(); </script>

Further Reading

  • Google Analytics Custom Variables
  • Google Analytics External Campaign Tracking

Tags: analytics, google, jquery ( Add Tag )

Bookmark This Page:
  • Digg loading
  • Delicious loading
  • Re-Tweet loading
  • StumbleUpon loading
  • DZone loading
  • Snipplr
  • Script & Style

Reply:

B U I Link Font Color Edit Preview ?
Characters: 0 Textbox Size: [+] [-]
   

  • New Comment
    #1

    Wed. September 8, 7:57:05 AM

Font Size:

  • A
  • A
  • A
  • A

Search:

Places:

  • Blog
  • Message Board
  • Chat Room
  • Geek Speak
  • Open Videos
  • Reviews
  • Tag Cloud
 

Site Links

Site

  • About
  • Contact Me
  • Site Map
  • Site Search

Interact

  • Blog
  • Geek Speak
  • Message Board
  • Open Links
  • Open Videos
  • Photo Gallery
  • Polls
  • Reviews

Random Stuff

  • Hosting by FatCow
  • © Copyright 2005 - 2010
  • Modified: Thursday, August 05, 2010
  • Load Time: 0.06 Seconds

Site Coded And Designed By Neal Grosskopf Using No Crappy CMS Or Themes