# Using default token values in custom module for unknown contact

**URL:** <https://community.hubspot.com/t/using-default-token-values-in-custom-module-for-unknown-contact/11301>\
**Category:** APIs & Integrations\
**Created:** [December 2, 2018, 8:42pm UTC](https://community.hubspot.com/t/using-default-token-values-in-custom-module-for-unknown-contact/11301 "2018-12-02T20:42:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kring](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kring/32/31639_2.png) [@kring](https://community.hubspot.com/u/kring)\
**Post date:** [December 2, 2018, 8:42pm UTC](https://community.hubspot.com/t/using-default-token-values-in-custom-module-for-unknown-contact/11301/1 "2018-12-02T20:42:04Z")

</div>

I have a custom module that replaces checklist values in a form with personalization tokens. If the contact doesn’t have the properties coordinating with the personalization tokens filled out, it alters to the default property. However, I can’t seem to make this work if the visitor is totally anonymous, because the code gives me an error unless I put it in an IF statement for contact being known.

**My hubl/html:**

Hubl & html

```auto
{% if widget.formQuestion %}
	{% set formQuestion = widget.formQuestion %}
{% else %}
	{% set formQuestion = "" %} <!-- assign a value to dynamicLabel1 in case contact is unknown -->
{% endif %}

{% if contact.email %}

	{% set dynamicLabel1 = "{{contact." ~ widget.dynamicProp1 ~ "}}" %}

{% set label_list = [] %}
{% for text in module.dynamicProp1 %}
 {% do label_list.append( "{{ contact." ~ text ~" }}" ) %}
 {% endfor %}

{% set label_listb = [] %}
{% for text in module.dynamicProp2 %}
 {% do label_listb.append( "{{ contact." ~ text ~" }}" ) %}
 {% endfor %}

{% set combinedLabels = [] %}
{% for i in range(label_list|length) %}
{% do combinedLabels.append( "{{ label_list[" ~ i ~ "] }} {{ label_listb[" ~ i ~ "] }}" ) %}

{% endfor %}
{% if widget.need_to_combine_a_second_property_ == true %}
{% set labels = "{{ combinedLabels|join(', ') }}" %}
{% else %}
{% set labels = "{{ label_list|join(', ') }}" %}
{% endif %}

<data 
 id="dynamicProps"; data-question="{{ formQuestion }}" data-labels="{{ labels }}">

	</data>

{% form
	form_to_use="{{ module.form_field.form_id }}"
	response_response_type="{{ module.form_field.response_type }}"
	response_message="{{ module.form_field.message }}"
	response_redirect_id="{{ module.form_field.redirect_id }}"
	response_redirect_url="{{module.form_field.redirect_url}}"
	gotowebinar_webinar_key="{{ module.module.form_field.gotowebinar_webinar_key }}"
%} 
{% endif %}

```

**My JS:**

JS

```auto
 $(window).load(function(){

var dynamicFields = document.getElementById('dynamicProps');
 var labels = dynamicFields.dataset.labels

 var formQuestion = dynamicFields.dataset.question;

 var options = $('input[name='+formQuestion+']').toArray().map(function(checkbox) {
 	return $(checkbox).val()});
 if (labels === "") {

 } else {
 var formLabels = labels.split(', ');

 for (var i = -1; i < options.length; i++) {
 $('input[value='+(options[i])+']').next().text(function() {
 return formLabels[i];})
 };
 }

//document.write(formLabels)

});

```

---

<div class="post-metadata">

**Author:** ![cbarley](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cbarley/32/82559_2.png) [@cbarley](https://community.hubspot.com/u/cbarley)\
**Post date:** [December 4, 2018, 5:33pm UTC](https://community.hubspot.com/t/using-default-token-values-in-custom-module-for-unknown-contact/11301/2 "2018-12-04T17:33:43Z")

</div>

spoke offline with kendra, she’s all set here ![]()
