How to obtain the CustomVar of GA at the session level

Source: Internet
Author: User
Previously I wrote "analytics's visitor category tracking". Recently, I want to change the visitor level by changing the session-level custom variables. I originally wanted to set the session-level user variables through user interaction, then, we can determine whether the visitor-level user variables are changed based on the changes in the session-level user variables to form a set of member data mechanisms, but the actual operations are

Previously I wrote Google Analytics's visitor category tracking, recently, I want to change the visitor level by changing the session-level custom variables. I originally wanted to set the session-level user variables through user interaction, and then change the user variables based on the session-level user variables, to determine whether the visitor-level user variables have changed, so as to form a set of member data mechanisms, but the actual operation is

Previously, I wrote "Google Analytics visitor category tracking". Recently, I want to change the visitor level by changing session-level custom variables.

Originally, we wanted to set session-level user variables through user interaction, and then determine whether the visitor-level user variables have changed based on the changes in session-level user variables to form a set of member data mechanism.

But the actual operation is not that simple. After setting visitor-level user variables, I can simply get the value. The specific method can be to read the utmz of cookies, or use the _ getVisitorCustomVar function.

However, session-level user variables cannot be obtained because session-level and Webpage-level variables are not stored in cookies, but are transmitted back to Google Analytics.

Although the _ getVisitorCustomVar function is used to obtain user variables, I can only obtain visitor-level variables in actual tests.

I define a function in the header and want to change the user variable according to the number of pages, visits, user behaviors, etc. However, a majority of the user variables have been deleted due to the failure, and the rest is just like this.

<? Php if (isset ($ _ COOKIE ['_ utm']) {$ visitutma =$ _ COOKIE [' _ utm']; $ lastlen = strrpos ($ visitutma, ". "); $ visitcount = substr ($ visitutma, $ lastlen + 1);} if (isset ($ _ COOKIE ['_ utmb']) & isset ($ _ COOKIE ['_ utmc']) {$ visitutmb =$ _ COOKIE ['_ utmb']; $ visitutmc =$ _ COOKIE ['_ utmc']; $ utmclen = strlen ($ visitutmc); $ countlen = strpos ($ visitutmb ,". ", $ utmclen + 1)-$ utmclen-1; $ visitpagecount = substr ($ vis Itutmb, $ utmclen + 1, $ countlen);} if (isset ($ _ COOKIE ['_ utmv']) {$ visitutmv =$ _ COOKIE ['_ utmv'];} if ($ visitpagecount <= 1) {?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.