views:

21

answers:

1

I am using the async version of Google Analytics along with custom variables and events. I have placed the tracking script (cut and paste from google) at the end of the section.

The custom variable is set above the tracking code in the head section. I'm assuming that Googles Analytics will send the data including the custom variable on page load. What happens if I have onclick triggered events? Will the custom variable in the head section get sent along with each event that is triggered as well?

I'm not sure how this plays out with javascript.

Thanks!

+3  A: 

It depends on the scope of the custom variable. Page view scope will only send/report the first time. You will have to include it in the onclick code that is triggered to get it to count each click.

If you have it as a visit/session scope, in the reports, it will associate itself for each click event for the duration of the visit/session.

Crayon Violent
I'm using a session variable to figure out what type of user they are. Should I be using a page level variable instead?
chobo
In general, you will want to use a session scoped variable to answer things like what type of user someone is. For instance, let's say you find out that the user is male or female. It makes more sense to trigger a session scoped variable with that info, and it will get tied to all the rest of the page views and events that happen during the visit. By contrast, if it were page view scoped, it would only be tied to that single page view or onclick event.
Crayon Violent