I'm trying to track phone sales vs. web sales using our existing web forms and google analytics.
Currently, when a conversion occurs, an object is created in the database, the primary key of the object is recorded in Google Analytics as a custom variable (with page level scope).
By creating custom report across the "campaign" dimension, which drills down to a "custom variable value 1" dimension I can see the custom variables associated with each campaign, effectively letting me collect all the specific database objects attributed to a particular campaign.
Complication: We want to take phone calls and submit forms ourselves (create conversions) for the customers. This means that multiple conversions will be happening in short succession originating from the same machine. We still want to attribute each conversion to a particular campaign. However, I'm unclear of the scope of the campaign/medium/source variables.
If I timeout the GA session multiple ''visits'' are reported, woohoo!
But mysteriously, the custom variables are simply not being recorded anywhere in analytics, either in the intended source or elsewhere.
What I'm trying to accomplish with the session reset, is based on the assumption that source/campaign/medium have session level scope, and that if multiple campaigns submitted apps in the same session, without the session reset, would the last set campaign get all th开发者_JAVA百科e credit?
relevant code:
_gaq.push(['_setAccount', 'UA-xxxxxxx-x']);
if(getParameterByName("reset_session") == "1"){ //reset google analytics session
_gaq.push(['_setSessionCookieTimeout', 1 ]);
}
//track pageview under new session
_gaq.push(['_trackPageview']);
//called when business logic dicates under specific circumstances
function register_conversion(){
_gaq.push(
['_setCustomVar', 1, 'DatabaseKey', _object_id + '', 3],
['_trackPageview', '/goal_url']
);
}
The notion of scope of campaigns and sources is not analagous with the notion of scope custom variables use.[1]
The campaign and source of a user is persistent (stored in a 6 month cookie), but every page/visit/user record is annotated with the campaign and source.
So for example, changing your campaign after several pageviews, during the same visit, will change all subsequent pageviews and the visit, but all prior pageviews remain under the scope of the previous campaign.
I discovered this experimentally, not through documentation.
[1]http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html
精彩评论