开发者

Pass extra data to Google Analytics

I h开发者_如何学Cave some good experience with Google Analytics and have been using it for years. I've done some basic tracking and some event tracking from flash and AJAX apps. I'm working on a project now that has detail pages about people, but the query string is an ID rather than a SEO-friendly URL. (e.g. bio.aspx?id=3945 vs. /bios/ursino-mark.aspx). I have the actual info about the person (like name) in ASP.NET and I'd like to somehow pass it to Google Analytics so we know more about the actual page in the report, other than just a number. I've looked into this and found Custom Variables in GA. I'm wondering if there are any other options/recommendations?


Based on the information you give in the question, Custom Variables are indeed the method you'd want to proceed with. (There's also the possibility of using the 'User Defined Variables', but their use is discouraged, as the feature is considered deprecated in favor of Custom Variables.)

In contrast to Events, Custom Variables don't create their own request to Google Analytics; instead, they define an attribute of the hits (events, pageviews, transactions) that result from the given custom variable scope. Thus, they're the best way to send extra data about something you're already tracking (ie, pageviews.)

In that sense, the best usage for you would be to set a page-level custom variable before the _trackPageview call with the name of the person in question, always in the same slot. (Since each bio page would be their own page, setting it at the page-level scope would prevent any variable-overwriting issues, as there would never be any overlap.)

In this sense, you can think of a custom variable being something that describes the page/session/visitor, rather than describing a particular interaction (which is what Events are better suited for.)


To push custom variables and events to Google Analytics use this method.

 _gaq.push(['_trackEvent',
    'Shopping', // category of activity
    'Item Removal', // Action
]);

You can learn more about tracking events from code.google.com: http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html


i would consider using virtual pages in the analytics. you can report all personal pages under the same virtual directory so that you will be able to easily filter out this data. something like /personal-pages/Mark-Ursino or /personal-pages/john-smith

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜