# Reading personalization token into a javascript var

**URL:** <https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678>\
**Category:** CMS Development\
**Created:** [March 27, 2020, 9:48am UTC](https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678 "2020-03-27T09:48:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![basvanKesteren](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/basvankesteren/32/76793_2.png) [@basvanKesteren](https://community.hubspot.com/u/basvanKesteren)\
**Post date:** [March 27, 2020, 9:48am UTC](https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678/1 "2020-03-27T09:48:28Z")

</div>

Hi,

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.

Thanks for helping.

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [March 27, 2020, 12:53pm UTC](https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678/2 "2020-03-27T12:53:40Z")

</div>

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

```auto
<script>
 var myJavascriptVar = {{ contact.my_custom_contact_property }};
</script>

```

There is also a new HubL function for this: [HubL functions - HubSpot docs](https://designers.hubspot.com/docs/hubl/functions#crm-object)

---

<div class="post-metadata">

**Author:** ![basvanKesteren](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/basvankesteren/32/76793_2.png) [@basvanKesteren](https://community.hubspot.com/u/basvanKesteren)\
**Post date:** [March 28, 2020, 6:32am UTC](https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678/3 "2020-03-28T06:32:49Z")

</div>

Thanks Stefen. Sometimes I overlook the simple things.

Any tips for coding a delay?

---

<div class="post-metadata">

**Author:** ![stefen](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/stefen/32/29274_2.png) [@stefen](https://community.hubspot.com/u/stefen)\
**Post date:** [March 30, 2020, 1:31pm UTC](https://community.hubspot.com/t/reading-personalization-token-into-a-javascript-var/19678/4 "2020-03-30T13:31:46Z")

</div>

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

```auto
if (window.location.search.indexOf('submissionGuid') > -1) {
 $('body').addClass('loading');
 $('body').append('<div class="loader"></div>');
 setTimeout(function(){ 
 window.location.href = window.location.protocol + "//" + window.location.hostname + window.location.pathname;
 }, 2000);
}

```
