# Compare personalization\_token value

**URL:** <https://community.hubspot.com/t/compare-personalization-token-value/22111>\
**Category:** CMS Development\
**Created:** [June 25, 2020, 3:46pm UTC](https://community.hubspot.com/t/compare-personalization-token-value/22111 "2020-06-25T15:46:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidFJones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/davidfjones/32/75439_2.png) [@DavidFJones](https://community.hubspot.com/u/DavidFJones)\
**Post date:** [June 25, 2020, 3:46pm UTC](https://community.hubspot.com/t/compare-personalization-token-value/22111/1 "2020-06-25T15:46:40Z")

</div>

Hey all,  
I’m trying to check if a value/property exists using a personalization token. I need to use the token as the value I am checking needs to be dynamic and change per each page.  
Currently this is what my code looks like

```auto
{% set lessonID = "1234" %}
{% set testvalu = personalization_token("contact."~lessonID,"null") %}
{% if testvalu == 'null' %}
 This checked worked
{% endif %}

```

The problem is that if the contact property “contact.1234” is not set, then this if statement is not firing.  
I have also tried setting a third value in between the testvalu and if statement

```auto
{% set lessonID = "firstname" %}
{% set testvalu = personalization_token("contact."~lessonID,"null") %}
{% set thirdTest = testvalu %}
{% if thirdTest == 'null' %}
 This checked worked
{% endif %}

```

but this still does not work. I can also confirm that “null” is being set, if I check either {{testvalu}} or {{thirdTest}}, null will be printed on the screen in this instance.  
The only other thing to add is I have tried using both single and double quotes when checking my null string value == “null” or == ‘null’ .  
Thank you

---

<div class="post-metadata">

**Author:** ![alyssamwilie](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alyssamwilie/32/2072_2.png) [@alyssamwilie](https://community.hubspot.com/u/alyssamwilie)\
**Post date:** [June 26, 2020, 7:22pm UTC](https://community.hubspot.com/t/compare-personalization-token-value/22111/2 "2020-06-26T19:22:43Z")

</div>

Hey @DavidFJones  
Usually you can just do

`{% if not testvalu %} {% endif %}`

or

`{% unless testvalu %} {% endunless %}`

to check if a value doesn’t exist.  
Eiher of these work for you?

---

<div class="post-metadata">

**Author:** ![DavidFJones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/davidfjones/32/75439_2.png) [@DavidFJones](https://community.hubspot.com/u/DavidFJones)\
**Post date:** [June 29, 2020, 3:11pm UTC](https://community.hubspot.com/t/compare-personalization-token-value/22111/3 "2020-06-29T15:11:27Z")

</div>

So I found that if I used pprint on a personalization token that it wasn’t actually just printing a string, it was printing a long list of characters/variables that made it unable to be compared to anything else.  
The solution was to instead call the property using square brackets. so

`{% set testValu = contact["lesson1234"] %}`

Using this now testValu can be compared to anything else like a normal variable
