I have had quite a few requests to confirm that you can read custom variables so I thought I’d just show a quick demo. I also recommend you take a look at the video from the Google Analytics team that describes this feature (fast forward to around minute 29:00).
As the name implies _getVisitorCustomVar() only reads custom variables that have a visitor-level scope. You can’t use this approach for reading page-level or session-level custom variables, so the scope should be set to 1 when you set a custom variable. The argument in _getVisitorCustomVar(1); is the slot you use for setting the visitor-level custom variable.
Anyway, here is a simple demo where we set a custom variable on another page. Once the custom variable is set, it can be read and be used to execute code on other pages.
Please click here first to set the custom variable. Then come back to this page and see what happens.
Follow me on
{ 5 comments… read them below or add one }
Great example! I can think of many cases where this will be useful…time for me to go tinker.
Thanks for the example,
Kurt
Nice! This is pretty sweet. Reminds me of a cool thing you can do to force someone to like your post on facebook before seeing the content you want them to see.
http://www.blackhatdigest.com/online-tools/check-it-out-facebook-forcing/
Cool idea, but hidding the div may be considered as cloacking by Google. How do you think?
The same issue applies to Website Optimizer for multivariate testing, where you show different content to different people, and it has been addressed by Google. As they say in the article, I personally don’t think there is a problem if you use it ethically.
There is no hiding a div with the code example from BHD there. It’s a php function – if the user is logged in it shows content. Since googlebot isn’t logged into facebook it doesn’t know there is hidden content.
No different than showing users different info depending on if they have an account at your site.