I've got a client who is setting up a system where a certain segment of visitors to a page "A" will receive a Javascript redirect to another page "B". (I know, not ideal but not my idea...)
They're using a Javascript tag-based web analytics solution (Omniture SiteCatalyst) which is deployed on both pages.
My question is, for visitors who we redirect, can we ensure that the redirect will fire and that they'll be "off" of page "A" before the page "A" web analytics code fires and triggers a page view?
Is there something that needs to be done programatically, and is there a more or less "foolproof" way to make sure that page "A"'s 开发者_如何转开发analytics code won't fire, or will any solution have some leakage depending on variations in browsers and net / client PC speed and so forth?
One way you can be certain is to return the JavaScript code that does the redirection, and nothing else. Is there any reason to load the contents of the page when the user will just be redirected, anyway?
In other words, in the server-side language of your choice:
if in experiment B:
emit javascript redirection template
else:
emit template for page A
Where, the JavaScript redirection template is nothing more than:
<script>window.location.href="path/of/page/B";</script>
You'd have to structure the code to look something like this (pseudocode):
if( on_page_a ){
if( user_requires_redirect ){
redirect( PAGE_B );
} else {
fire_analytics( PAGE_A );
}
} else {
fire_analytics( PAGE_A );
}
Hope that makes sense
精彩评论