简体   繁体   中英

How to read Universal Analytics cookie (acquisition) data?

On my Website im using normal Universal Analytics code. I want to extract acquisition data from Analytics cookie so i can use it in my contact form (or somewhere else), so wen users sends an email i can see his acquisition data, for example: stackoverflow.com/referral or google/organic : keyword1 or bing/organic : keyword2 or direct/none or newsletter/email : campaign1 or newsletter/email : campaign2 ...

I have been searching and found these two links that describe something similar but for classic analytics and i cant get it to work with universal:

http://www.dannytalk.com/read-google-analytics-cookie-script/ 

https://productforums.google.com/forum/#!topic/tag-manager/VIgRiSAK32Q

Can anyone help me with this?

You cannot get it to work with UA. The only thing Universal Analytics stores in the cookie is a client id. Everything else is calculated on the server from the information that is sent with the first pageview in an session.

You can at least partly emulate the function that determines the aquisition data - if it has campaign parameters (utm_source,utm_medium etc) you can use those.

If the referer has google, bing, yahoo and the parameter "q" in it it's organic search traffic (of course there are more search engines, you'd have to build a list with domain names and search parameters). From ssl encrypted you will not get the keyword, else you'd extract this from the parameter in the referer that the search engine uses to transmit the search term (with Google, bing, Yahoo this is "&q=searchterm").

If the referrer is not in your list of search engines it's a referral visit. If there is no referer it's direct traffic. If there is a glcid it's paid traffic from Google Adwords.

That way you can build something that should quite resemble the Google Analytics aquisition data, but you cannot get this from the single value in the Universal Analytics cookie.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM