Contact variables delay

Highlighted
Occasional Contributor

Hi all,

I'm trying to get a contact parameter on a thankyou page to send a GTM event.

<script>
dataLayer.push({'event': 'lead', 'myvar': '{{ contact.myvariable }}' });
</script>

Unfortunately, i only see the old value (if present). The form-submitted value is only present on the next request.

 

Example:

//Submit form with myvariable=A
//See myVar='' in thankyou page
//Submit form with myvariable=B
//See myVar='A' in thankyou page

 

What's wrong?

4 Replies
Esteemed Contributor

@lucabartoli like you said, there is around a 5 second delay (in my experience) before the contact record gets updated. In the past I have added a script on the TY page to check for a parameter in the url and refresh the page after a couple seconds and remove the parameter. It's a little hacky, but it worked for me.

Reply
0 Upvotes
Occasional Contributor

Any way to pass this parameter as a get parameter to the thankyou page?
If so, i can retreive it with 

{{ request.query_dict }}
Reply
0 Upvotes
Occasional Contributor

I solved this by adding the field in the redirect url as get parameter.

https://gist.github.com/flexgrip/0ef20e183ca7fe577b5d309620fc44bc

Esteemed Contributor

@lucabartoli nice! will have to check that out next time I'm in need of that.

Reply
0 Upvotes