I need a little help.
I am trying to pass data from a Cookie inside of GTM to a custom attribute inside of Drift.
I've tried following this documentation, but can't seem to get it to work: https://devdocs.drift.com/docs/contact-properties
This is the code that I have tried using inside of Google Tag Manager:
drift.on('ready', function() {
drift.api.setUserAttributes({
gclid: '{{cookie - gclid}}'
})
})
I am not very familiar with coding, so I am sure there is some error on my end. Any help would be appreciated.
It's quite challenging to help without knowing what the errors are, but I'll do my best.
The issue is most likely related to either the Drift integration failing to initialize or an error related to accessing the cookie. The best way to solve your issue would be to isolate where the problem lies.
Focussing on Drift, are you sure that Drift has been initialized correctly?
According to the documentation, a custom Drift attribute will be visible in the Custom attributes tab in your contact settings.
You can test this by running the following code snippet in the browser console for the website in question and then checking the Custom attributes tab to check that the
test
attribute has been created.Note that Drift does not initialize when running a website locally so make sure that you're testing with a site that's deployed to a server.
If the above works then we know that Drift is working as expected and the issue relates to how you're accessing the cookie so you'll want to focus on that.
In either case, if you could share your error, it would be very helpful.