views:

73

answers:

2

What is the difference between the two? I have an Ajax heavy site and I'm not sure which one would be more appropriate to use for tracking requests.

A: 

Event Tracking would probably be better suited to AJAX interactions. Custom variables get set, then posted after ._trackPageview() is called. Event tracking can be used after you page has loaded and called ._trackPageview(), and then your user performs actions that may not result in a new page view, like AJAX calls.

Jonathan Bates
So custom variables can not be called after the page has loaded, whereas event tracking can be?
chobo
Short answer: yes. Your code would call ._setCustomVar and then ._trackPageView. You could set the custom variables to something else and then call ._trackPageView again, but this will skew your analytics numbers.
Jonathan Bates
Would you know any good real world examples where one person would use custom variables? I don't quite get the purpose for them.Thanks
chobo
+1  A: 

Event tracking is most suitable for tracking events in an application that don't necessarily cross page boundaries, such as actions implemented as Ajax calls.

Page level custom variables can be used to record user interactions, however the number of page level custom variables is limited to 5 per page. All custom variables must be defined before _trackPageview() has been called. I find session and visitor level custom variables more useful for recording extra information about a visitor such as demographics or anonymous vs logged in visits, which you can use to segment visitors.

donalmacanri
When using custom variables do you call the _trackPageView() method manually or is this handled by Google automatically?
chobo
The _trackPageView method is included in the piece of code that Google gives you to copy and paste into each page. As long as your code calls _setCustomVar before the Google code snippet, it should work.
donalmacanri