Tracking Dynamic Sites With Google Analytics
June 14, 2006 by Justin CutroniIn a previous post I mentioned that Google Analytics now offers an installation guide to help users hit the ground running. To further help GA user’s I’m writing a number of posts about common installation and configuration issues. Stuff that I encounter often.
Today I’m going to talk about dynamically generated websites. Dynamic websites use query string variables to change the content that is displayed in the browser. What’s a query string variable, you ask? Query string variables appear in a URL after the question mark. Here’s an example. The query string variables are bolded in the URLs below.
www.foo.com/index.php?aid=23
www.mysite.com/default.asp?cid=3847290&did=44jksaj9
Dynamic websites use query string variables to change the content displayed to the site visitor. The site visitor may request the index.php page 10 times but receive different content in the browser window each time the page loads because the query string variables change with each request. Dynamic sites are usually programmed in a language like PHP, .NET, ColdFusion or Java.
So why does all this matter to Google Analytics? It is important to understand what Google Analytics considers a unique website page. When a user lands on a page the urchin.js tracking code collects the value that is in the location bar of the browser. It then strips off the domain name and considers the remaining string a unique page on the website. This string includes all of the query string variables. Here’s an example.
http://www.website.com/shirts/index.php?aid=123
In the above URL Google Analytics would log a hit for /shirts/index.php?aid=123 in your reports. The query string variable aid=123 is important because it indicates the content that was shown to the visitor. If you are the site owner aid=123 will probably mean something to you.
If you have a dynamically generated site you really don’t need to do anything to your GA configuration. As described above, GA uses all of the query string variables when creating unique page names.
But what if you have a large number of query string variables that are not relevant to the content being display? You can configure each GA profile to exclude certain query string parameters when creating unique page names. This setting is found in the ‘Main Website Profile Information’ section of the profile settings. Simple list all of the query string parameters that you want GA to ignore.
Analyzing your query string parameters and excluding the irrelevant ones is a very important step in configuring your profile. Here’s why. Imagine that every visitor to your website has a unique identifier in the query string. That means that there will be a huge number of unique URLs that really aren’t unique. Your reports will be filled with useless data. Make sure you configure your profile to exclude all session identifiers from the query string variables.
Subscribe:








14 Responses to “Tracking Dynamic Sites With Google Analytics”
thx dude. I spent hours in writing a RegExp Rule deleting the SID query string…
Finally i found this Post which makes everything more easy.
By Luke Skywalker on Aug 18, 2006
Hi,
My question is quite specific.
My google analytics accounts is set up and I am tracking 4 of our websites. The following two are of concern
1. http://www.splashplastic.com - tracking code UA- 830077 - 7
2. http://www.quiditycard.com - tracking code UA- 830077 - 8
When customers goto either site and click on apply not the same portal opens portal.prepaytec.com
how can i put the tracking code on the confirmation page as when the confirmation page is reached, it could be reached from either site as the page is dynamically generated.
Our IT department says that we shouls set up the code as
_uacct = “UA-830077-X”;
urchinTracker();
where the “X” will be inserted dynamically depending on which site a customer is applying from. Is this the right way.
is there another solution which is easier?
In essence, we have a confirmation page which could be generated/called by a number of different websites and i need to know how we can put google analytics tracking code on this confirmation page to track all the different sites.
Kind regards
Amit Sharma
By Amit Sharma on May 15, 2007
Hi Amit,
The problem you’re going to run into is cross domain tracking. The idea that the IT guys have will work. However, you’ll still need to transfer the tracking cookies to the prepaytec.com domain. That’s done with __utmLinker(). You may want to read up on cross domain tracking:
http://www.epikone.com/blog/2006/09/26/google-analytics-configuration-mistake-3-third-party-domains/
HTH,
Justin
By Justin on May 16, 2007
Great post. Very helpful.
One question though, when you add the query string parameters to be excluded, can you see historical data with them excluded, or does GA just do it from that point forward?
By Mat on Oct 4, 2007
Hey Mat,
Changes to your GA configuration are not retroactive. Historical data will not be modified after adding the query string parameter.
Thanks for the comment,
Justin
By Justin on Oct 6, 2007
Is there a way to add extra information on the page being logged? For example, I want to store a page name along with the dynamic page so that the reports are easier to read. As it is now you can see that the page with id 123 is being hit the most, but the user viewing the reports then has to go to another page or system to lookup what page 123 actually is.
It would be nice if I could view something such as below.
/article.aspx?cntid=123 Deli page
/article.aspx?cntid=456 Cooking page
/article.aspx?cntid=789 Store Page
By Shawn Palmer on Jan 25, 2008
In addition to my previous question I would like to be able to log a page once with the query string and once without. For example, I want to know how many users are viewing recipes on our site and I want to know which recipe are the most popular.
Specifically, how many users are hitting /Recipes/RecipeDetails.aspx and out of those which recipes are the most popular such as /Recipes/RecipeDetails.aspx?recipeid=123.
I know that I can use the filter to get a count, but then I have to compare that number against other reports manually. RecipeDetails.aspx may be the most popular page on our site, but I cannot tell this because I have the recipe id in the query string.
By Shawn Palmer on Jan 25, 2008
What I would be interested in seeing is how people handle dynamic form pages that submit the data back to themselves, process it, and return a success or failure message. How would I track the success and the failures separately than hits to the form version of the page?
By Chester Bullock on Feb 20, 2008
Hi Shawn,
To answer your first question, yes. You can add extra data to the URI. You’ll need to use a filter to manipulate the data in GA.
If you would like to log the data in multiple ways then you will want to create multiple profiles. Remember, all of these settings are profile specific. So, by changing the settings from one profile to another, you can manipulate the data.
Thanks for reading,
Justin
By Justin Cutroni on Jun 24, 2008
Chester,
If you have a dynamic form then you need to programatically manipulate the Google Analytics tracking code each time the form posts back to the server. Google actually has a help document about this topic:
http://www.google.com/support/analytics/bin/answer.py?answer=55576
Thanks for reading the blog and I hope that helps.
Justin
By Justin Cutroni on Jun 30, 2008
The site I gave is the site in question. It is a DotNetNuke site created to bring multiple existing sites under one domain. Each site is accessed through a portal. I want to track the activity to the whole domain, as well as each individual portal. However, the portals appear as subpages http://www.domain.com/portalname. Is there a way to track sub-page groups in a separate account? Thanks.
Lorianna
By Lorianna Sprague on Jul 29, 2008
Hi Lorianna,
You have a lot of options here. Based on your description, it sounds like you need to do some work with filters and profiles. You could put one piece of tracking code on all pages and then segment the data into different profiles using filters. You could create one profile for each of the portals.
You also mentioned segmenting the traffic into different accounts. This can be done, but tracking traffic in multiple accounts can be tough. You can’t simply copy and past multiple versions of the code on your site. You need to create multiple tracking objects if you’re using ga.js or reset the tracking if you’re using urchin.js.
Hope that helps.
Justin
By Justin Cutroni on Jul 29, 2008
I’m using the code GA provided and placing it where it said to place it, before . Some of the coldfusion pages don’t have . Could I place it before or would it not track the page?
Sorry for double posting.
By Ben on Oct 15, 2008
Ben,
You can place the code anywhere in the body. Just make sure it’s in a logical place. Don’t place it in the cell of a table. :)
We like to place it at the bottom of a page to make sure that the entire page has rendered before requesting ga.js. That’s to insure the page has rendered before requesting GA.JS.
Justin
By Justin Cutroni on Oct 29, 2008