Implementing Custom Variables

Contact Us or call 1-877-932-8228
Implementing Custom Variables

Implementing Custom Variables

Your code for creating a custom variable must be placed prior to the _trackPageview() method.

Consider that you are managing a website for an online magazine which offers different types of articles for their visitors to read. You want to determine which category is more popular. You can accomplish this task using custom variables.

You will need to define custom variables at the page level for every single article based on how you wish to categorize your articles. Your code snippet may look like:

_gaq.push(['_setCustomVar',1,'Article Category','Technology',3]);

In the above example you are assigning your custom variable to slot number 1. You are labeling your custom variable as Article Category and for this particular article you are setting the value = Technology. Since this interaction is happening on a pageview level, the scope of your custom variable is set to 3.

Next