I am trying to get the data from a personalization token into a javascript var. Is this possible?
I have a form where people can score on 5 questions. The average of the 5 scores are put in a var “averageScore” (via Javascript). This averageScore is put in a hidden form field (average).
When people submit the form, they get a landingpage with a Google Graph (bar) and it must show the the average.
@basvanKesteren yes, it’s possible. In the past when I’ve done this you do have to add a few second delay for the personalization token to populate with the value. Usually it takes a bout 5 seconds after the form was submitted from my own experience.
In your coded template, or in the HubL section of a custom module, you can do this:
<script>
var myJavascriptVar = {{ contact.my_custom_contact_property }};
</script>
@basvanKesteren last time I did something like this I used some javascript on the thank you page that checked for the “submissionGuid” query parameters in the URL which would trigger a loading spinner and then refresh the page after a couple seconds. Here’s the example code: