Tracking Individual Clients on Database-Driven Pages Using Google Analytics

Here’s a question we have been asked recently:

We run a centralized application that manages different websites. It’s a database driven set of pages that, depending on a URL variable, displays a specific client’s content.

(ex. clients-domain-A.com/index.asp?ID=93874X6E830T displays client A’s content
clients-domain-B.com/index.asp?ID=76UHHEI8769 displays client B’s content)

A critical note is that each client’s domain name is not configured as a website in IIS; we simply direct all domain names to the same IP and use a script to associate the domain name with a client’s ID. Currently, we have about 100 clients, but the implementation must be scalable to as many as 400.

So the questions we have are…

  1. Is there a way for us to use Google Analytics to track statistics independently for each client?
  2. Would I have to install all Google Analytics tracking codes in the same page?
  3. Can Google Analytics track a profile based on the domain name only?

Well, there a couple of solutions to this particular problem that you could try (they haven’t been tested). Both of them involve creating separate profiles for each client.

Database copy.jpg
Creating a new field (in MS Access)

One solution is to add a field to the customer database that is being used to generate the pages, called ‘Google Analytics ID’ or some appropriate field name. This field should consist of the account ID given to you in the implementation script of the corresponding profile.

Tableview.jpg
The New DatabaseIn the script that generates the page, you need to include a section that writes the Google Analytics script into the page. In this section, you can have the __uacct variable set using the ‘Google Analytics ID’ field from the database.


script.jpg
Code Generated For John Doe
This way, you only have to include the script once (to answer part 2), and it will be appropriately written depending on the client’s ID. This, of course, depends entirely on how your website is generated (what language, etc). Our example uses ASP, so we’re fine.

To answer the third part of the question, Google Analytics by default tracks pages using the URI, not the domain name. This allows us to ignore the dynamically generated domain names.

An important thing to keep in mind is that Google currently only allows 50 separate profiles per Google Analytics account. In order to track more than 50 clients, you would need to create a different account for every 50 clients you wish to track.

Fortunately, using the database method, you would not have to alter anything in order to integrate these new accounts, as long as you correctly identify the appropriate Analytics ID in the database for each client. You would not need to create a new database for each Google Analytics account.

Alternatively, you could use an include filter for each separate profile that grabs the particular client’s ID number from the query string. This would be fine if the number of clients will remain small, but since we’re looking at potential growth up to 400 clients, it’s really not an option.

So, as we’ve illustrated, even though Google Analytics may not track large-scale website configurations right out of the box, with a little forethought and proper planning, it can support more complex and/or dynamic sites.