Reputation: 239
A client has a web form that would like to include (via hidden inputs) the campaign, referral, source and other UTM tags that are usually sent across by google analytics but since the upgrade to universal analytics i don't seem to be able to find them in the traditional __UTMZ cookie. The goal here is to get the data into the html inputs. Any suggestions on how to get the values via JS?
Upvotes: 2
Views: 3016
Reputation: 566
Universal Analytics does not store the campaign information in a cookie anymore, therefore you are unable to retrieve it. What you can do is:
Keep on using the old Google Analytics code (ga.js). You can run ga.js side by side with the new UA code (analytics.js), employing ga.js just for the UTMZ cookie creation and retrieval. But the support for ga.js will be discontinued at one point probably.
You can create your own cookie that will store this information. Try this project to achieve it: https://github.com/dm-guy/utm-alternative. It creates a new first-party cookie that stores your campaign data, taken from the tagged URLs, and so makes this data retrievable; it also allows you to retain the old UTMZ cookie values by storing them in the new cookie.
Upvotes: 4