The default Google Analytics configuration on your site will send over the usual information: geographic location of your visitors, what browsers and operating systems they're using, page clicks, page load times, etc.
However, Google Analytics also has the ability for custom variables, and the Drupal 7 Google Analytics module (and Drupal 6 versions > 3.1) has the ability to set those up.
But first - an introduction....
Introduction to Google Analytics custom variables
What if you want some additional information about the visits to your site? Perhaps you're selling products and you'd like to be able to see, at a glance, which product categories are the most visited. Perhaps you want to see which user roles visit the site the most/least, or what hour of the day is the most popular for your site. You can do all of these with custom variables.
Custom variables have three scopes:
- Page level
- Persists only as long as the current visitor is on this page
- Visit level
- Persists for the visitor's entire site visit. Does not get sent with each different page the visitor is clicking on
- Visitor level
- Persists for 24 months as a cookie on the user's computer - so for multiple visits.
Examples of variables for each of these scope levels are given in this thorough blog post by Justin Cutroni.
Using Google Analytics custom variables on your Drupal site
Login as admin and go to /admin/config/system/googleanalytics or
Configuration --> System --> Google Analytics
At the bottom of the screen is a collapsed section called 'Custom Variables'. Expand that section, and you'll see you have room to set 5 custom variables to be sent to your Google Analytics account.
For each variable, you have to choose:
- a name,
- a value to be sent, which you will select using a special interface Drupal provides to make sure you're choosing a token that is available to be sent, and
- the scope
To create a new variable, choose a name and scope and then place the cursor in the corresponding 'Value' textbox. Then, simply click on the 'Browse available tokens' link at the bottom of the collapsible section (which is not displayed on the screenshot above). A pop up, like the below, will appear, and you can select the token you want sent with that custom variable. Times of day, user names, roles, and node fields (including tags) are all available!!
Browsing custom fields in Google Analytics
After setting up the above, wait a day or so for the new data to come into your Google Analytics account. The custom variables are under the 'Audience' section.
Once you're on the right page, you may notice that all your custom variables are not placed in one list, and you may have to tab through with the links at the top!
This can open up a whole new set of possible statistics about the sections of your site, as you start using your tags and fields as a way to measure visitor activity!