CMS Development

lucabartoli
Member | Diamond Partner
Member | Diamond Partner

Contact variables delay

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 4
stefen
Key Advisor | Partner
Key Advisor | Partner

Contact variables delay

@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.

Stefen Phelps, Community Champion, Kelp Web Developer
0 Upvotes
lucabartoli
Member | Diamond Partner
Member | Diamond Partner

Contact variables delay

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

{{ request.query_dict }}
0 Upvotes
lucabartoli
Member | Diamond Partner
Member | Diamond Partner

Contact variables delay

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

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

stefen
Key Advisor | Partner
Key Advisor | Partner

Contact variables delay

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

Stefen Phelps, Community Champion, Kelp Web Developer
0 Upvotes