Custom Variables in Google Analytics

Rate this post
Custom variable in Google Analytics allows you to define and track custom user interactions other than those already provided. Custom variables allows you to track the user activity in your site as per your own needs.

How to Set Up a Custom Variable?

You will need the following code in setting up your own custom variable –

_setCustomVar(index, name, value, opt_scope)


Custom variable accepts four parameters given below:- 


Required Parameters


Index – This is the slot for the custom variable and contains a  numeric value ranging from 1-5

Name – The name of the variable is defined here.


Value – The value of the variable is defined here. 


Optional Parameter


Opt_Scope – Page level, session level or visitor level interactions can be defined here.


Example of Setting Up an Ecommerce Custom Variable



Suppose, I am the owner of an ecommerce website and I want to track the number of visitors who are interested in viewing the “Electronics” section of my website. I will set up a custom variable to track this interaction using Google Analytics. 


_gaq.push(['_setCustomVar',
          1,                   // Custom variable is set to slot #1.  Required parameter.
          'Category',       // Name for your Ecommerce store content categories.  Required parameter.
          'Electronics',           // Sets the value of "Category" to "Electronics".  Required parameter.
          3                    // Sets the scope to page-level.  Optional paramete.
         ]);





Also See:- 


How to Create a New Dashboard in Google Analytics?
Google Makes Improvements in Real Time Reports
Difference Between Clicks and Visits
Understanding Goal Flow in Google Analytics
Google Tag Manager
Multi Channel Funnel in Google Analytics
Regular Expressions on Google Analytics
Search Queries in Webmasters Tools
Google Data Highlighter
Seo for E-commerce Websites
Seo Tutorial
Stop words in Seo