APIs & Integrations

Not applicable

Formatted Personalization Tokens

Hi,

I have a contact form that when a user selects a checkbox, it runs through a workflow and then sends an internal email.

In this internal email it needs to populate a url param with contents of the form.

Example:
/?email={email}&UserFullName={fullname}&CompanyName={companyname}&phone={phone}

The problem falls mainly with the Company Name if I just use the regular token for this and the company has a space in their name it breaks the link.

I need to add a + where the space would be, it should look like Some+Company+Inc.

Thanks,
Vinny

0 Upvotes
13 Replies 13
Not applicable

Formatted Personalization Tokens

@pmanca

I found a work around. I created another field that was hidden, then used javascript to grab the value of the company field off focus. It then removes the space and adds the + then puts it in the hidden field.

I then use the personalization token of the hidden field in my email because it already was sent with + in there.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz very cool! thanks for posting it here to help others who run into this problem down the road.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz

You can use hubl to re-format the string that comes in from the personalization token. Take a look at these docs here for a jump start on it.

0 Upvotes
Not applicable

Formatted Personalization Tokens

Is there something specific I should be look for? I just did a quick scan of it and I cant seem to find anything that will be able to run something like a regex to replace a space with a +.

0 Upvotes
Not applicable

Formatted Personalization Tokens

i am trying to use the replace() function, but it is not working.

{{contact.company|replace(' '),'+')}}

it still displays with the space and not the +

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz

It looks like you have an extra ‘)’ in your code

Try it with this first

{{contact.company|replace(’ ‘,’+’)}}

If that doesn’t work let me know and I can create a working example on my end

0 Upvotes
Not applicable

Formatted Personalization Tokens

@pmanca

that isnt work either, does replace() work in email templates?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz Yes they do, I just tested it out on an email template and saw success. Here wast the test code I used.

{% set test = "test1 test2" %}
    
{{test|replace(' ','+')}}
0 Upvotes
Not applicable

Formatted Personalization Tokens

@pmanca yes that seems to work, i got that working as well, i can not get it to work with {{contact.company}} the personalization token wont take the replace.

i tried to set contact.company as a new variable and trying it on that too but if i do
{% set companyName = {{contact.company}} %}
i get an error because it thinks im trying to create an array.

0 Upvotes
Not applicable

Formatted Personalization Tokens

@pmanca

{% set companyName = "{{contact.company}}" %}
<p>{{companyName}}</p>
{% set dirtyCompany = "{{companyName|replace(' ','+')}}" %}
<p>{{dirtyCompany}}</p>

I just tried this, this doesnt work either. It seems like you can not modify a personalization token at all.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz you are actually correct. My apologies. I did some more testing on my end and then confirmed with my manager @zwolfson that in the email took the personalization tokens are loaded after the hubl logic is executed so you cannot modify a personalization token as you mentioned.

0 Upvotes
Not applicable

Formatted Personalization Tokens

@pmanca

So then there is no way for me to do what I need?

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Formatted Personalization Tokens

@iamcenz no there doesn’t appear to be. If I come across a solution I will let you know .

0 Upvotes