In 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.
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.
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
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
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?
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
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
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.
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?
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
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
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
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
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.
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
my question is. I have an index page with an automatic refresh script that forwards the visitor automatically to my main home page. If I place the Analytics code into the index.html page, will google analytics work? or do I have to place the code into my home.html page?
Hey Tom,
I’m assuming that the forward is some type of server side redirect. That means that you can’t put GA on that page and, even if you did, it would never work. The page needs to render in the visitor’s browser to track correctly.
Make sure you place the code in the page that the visitor ultimately sees.
Thanks for the question,
Justin
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?
RNT,
Any changes that you make to GA today will not affect historical data. Once the data has been processed it can never change.
Justin
Hi all,
Great post !! , I have a question to know about the working of GA.
We have developed an dynamic content base /cms (only dynamic text ) using MS-sql database to one of the web site . Does GA work’s for only query string parameters on the url ? or can it be used non query string parameters.
We are pulling the record information from db and make it to reflect on the page dynamically using stored procedures(where in all query’s will be present in database and as well it wont be displayed on the url.)
can we use GA without the non-query string on url methodology ?
Darshan
@Darshan: Google Analytics will automatically collect the entire path in the location bar of the browser. This includes everything after the domain extension. If you are looking to collect information that is embedded on the page then you may want to try using a feature called Event tracking. This lets you collect almost any type of information in Google Analytics.
Is it possible to apply campaign tags to a dynamic URL?
@Ravi: I’m not sure that you really need to. The campaign tags need to be applied to the link in your marketing material, like the link in an email or PPC campaign. You do not apply the links to the pages on your site. After someone clicks on a tagged link and lands on your site, Google Analytics will store the data and apply it to the entire visit.
Hope that helps!