APIs & Integrations

punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Hi,

I need to get the Contact ID or Contact Email Address (plan b), for the user/contact the email is being sent to, in the email template!

In the hubL docs ( https://designers.hubspot.com/docs/hubl/hubl-supported-variables ), I can read "This variable is a dictionary that stores contact personalization properties for a known contact. Properties can be accessed from this dict, by adding a period and the property name. For example, contact.firstname would print the first name of a contact."

I tested with {{contact.id}} but that doesn't work https://foobar/?cid={{contact.id}} returns https://foobar/?cid=&utm_campaign=xxxxxx&utm_source=hs_email&utm_medium=email&utm_content=xxxxxxxxx...

Seems that it's not possible to get the contact ID in the template email?

0 Upvotes
1 Accepted solution
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Hi @punkbit, I certainly understand your frustrations here. It's understandable to be frustrated that you can't surface info like hutk or vid very easily.

That said, in order to work with you toward a solution it's impossible to address if I'm not able to respond and give my view here. If you could please allow a response so we can continue having a conversation on this in a productive manner that would be awesome, otherwise I won't be able to help. I'm certainly able to send your feedback internally so I'll make sure the product team knows of the shortcomings you listed.

However, one thing I'm confused about at the moment is that I'm able to see personalization tokens in my HubSpot Account populate. How are you testing that your personalization tokens work or not? Per this article

Click the Receive email as a specific contact dropdown menu if you want to test any personalization tokens used in the email, or leave it blank to preview sending the email to an unspecified contact.

When I go ahead and test out a few custom properties in my own HubSpot Account that I know have specific values, I'm able to see a value for each of those fields on my own test contact. Here's my HTML:

And this is how I set up a test email in my account:

And finally, what I receive when I receive the test:

As you can see, all fields are populated. They match the contact's information in my CRM as well. You must test out personalization tokens viewing as a specific contact. If that contact doesn't have those fields filled out, then nothing, or the default if you have one set, will show up.

Are you testing this way? If so, which contact are you testing with in your HubSpot portal? I'd like to try testing with that contact as well so that I can reproduce your issue with the empty values, but you should absolutely be able to use custom properties as personalization tokens as I showed in the screenshots above.

View solution in original post

0 Upvotes
27 Replies 27
cbarley
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Agreed it should be a bit more explicit. I'll give feedback to our knowledge team.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Sorry about the lengthy post but that was my effort and was sharing the experience, as personal notes, for your team to trace and future reference; And also sharing some workarounds, scraping the html as last resort which would be extremely costly in terms of computing resources.

Appreciate your help @Connor_Barley

cbarley
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

One thing I forgot to mention is that the vid property I have in that email was copied from vid to the custom property using a Node program that I made. I ran the program and the values for vid were copied to the custom property. I dont' know if you've done this yet and it would be a bit costly with API calls, you only have around 8k contacts so you wouldn't go over the 40k daily limit. If you're interested in running it, my code can be found here: https://codepen.io/cbarley10/pen/vQdyJP

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

The tests were done using the Send Test Email, but I haven't use the "receive email as specific contact", instead just placed one of the emails I have in the contact list, that I have access too. If that's what makes it work, great! I'll try it now!

punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

That's great! Thanks @Connor_Barley, I can see the data!

I didn't know that to test the personalization tokens, we have to view as a specific contact. The contact to test was placed in the email input "Choose one or more recipients", when choosing an existing contact it should return the contact data to avoid confusion, I must say.

I have the same or similar implementation in node for vid.

Hope this post helps someone else in the future.

cbarley
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Great, glad to hear it @punkbit. Yeah the contact has to be specified, otherwise there's no way for HubSpot to know which value to display. And then if there's no default value set on each token then nothing will be returned at all. Glad I was able to help, though!

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Ok @Connor_Barley but that should be a bit more clear, as I picked a contact in "choose one or more recipients", to avoid confusion we shouldn't need to pick the same twice (redundancy), on both fields, if that's the case; I understand it can be useful or required when testing someone else's email address, etc. All the tests were done using @getnada temporary email inbox for that matter.

cbarley
Solution
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Hi @punkbit, I certainly understand your frustrations here. It's understandable to be frustrated that you can't surface info like hutk or vid very easily.

That said, in order to work with you toward a solution it's impossible to address if I'm not able to respond and give my view here. If you could please allow a response so we can continue having a conversation on this in a productive manner that would be awesome, otherwise I won't be able to help. I'm certainly able to send your feedback internally so I'll make sure the product team knows of the shortcomings you listed.

However, one thing I'm confused about at the moment is that I'm able to see personalization tokens in my HubSpot Account populate. How are you testing that your personalization tokens work or not? Per this article

Click the Receive email as a specific contact dropdown menu if you want to test any personalization tokens used in the email, or leave it blank to preview sending the email to an unspecified contact.

When I go ahead and test out a few custom properties in my own HubSpot Account that I know have specific values, I'm able to see a value for each of those fields on my own test contact. Here's my HTML:

And this is how I set up a test email in my account:

And finally, what I receive when I receive the test:

As you can see, all fields are populated. They match the contact's information in my CRM as well. You must test out personalization tokens viewing as a specific contact. If that contact doesn't have those fields filled out, then nothing, or the default if you have one set, will show up.

Are you testing this way? If so, which contact are you testing with in your HubSpot portal? I'd like to try testing with that contact as well so that I can reproduce your issue with the empty values, but you should absolutely be able to use custom properties as personalization tokens as I showed in the screenshots above.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

It seems that Hubspot doesn't pass to the surface custom properties that do not have a default value, for some reason. Also, it doesn't pass to the surface any that is filled, so for example email or investment_status, as explained above! Even though this is a workaround, there is a bug in how hubspot works (now please don't start with excuses, it does not work, and I already gave my opinion about your policies and restrictions regarding properties, scroll up for your joy).

The property with a default value shows in the email template {{contact}} dump:

Now, I'll update the property on contact creation with the value.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

So, after spending all the time and energy for this workaround, the custom field that is updated, according to Hubspot own system, is not available in the email template, returns the default value... go wonder!

You can clearly see in the screenshot that the property MY_CONTACT_FREAKING_VID changed to 3287001

Lost my patience, trying to do workarounds and all that for what? Hubspot fails all the time, is not reliable, dah dah dah ladi ladi...c'mon!

Now what, should I wait an hour until the Property Value is available? C'mon!

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Just to remind you that the documentation is absolutely misleading, it's not correct, it's false.

Let me guess, now a Hubspotter is going to say that it's not supposed to work in the email templates?

I only tested using "send test email" for this particular case, should I try to send a proper email, will that work? Should I waste another few minutes on that...? c'mon you people, what a joke

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

I'm going to try a different workaround, that I'll explain later; For now would like to say that, if for example the {{ unsubscribe_all }} page is a customisable page, we can place a script that takes the user to our web app; passing some computed query parameters from the DOM, such as the email etc. That won't work for browsers that are not running javascript, or might look strange if there is a delay and a forced redirection. So, let's forget about this one for now and move on.

Now, moving to other findings and approach around this (which makes the whole Hubspot "NO VID" or "NO CONTACT" to our Hubspot users silly, just to say the least). Let's look into how Hubspot manipulates urls:

This is the output we get in the email client:

25

1) Link has Extra Query Params

or

2) Link has Extra Query Params

If you click any of the links above, you are taken to the original SRC in the template, plus some extra Hubspot query parameters, such as the umt source etc and _hsenc

The query parameter _hsenc is what's required to identify the email contact. On our side, I have:

https://foobar/hs/manage-preferences/unsubscribe-all-test?d=eyJlYSI6ImhlbGRlckBtb28ubGEiLCJlYyI6Miwic3Vic2--FOOOOOOBAR-WQiOjEsImV0IjoxNTQyODA0MDA1MTU1LCJldSI6ImI4Zjc2OTBmLTM5ZjUtNDVkZC1hZTI1LTNhMTU4Y2QxZTU5ZSJ9&v=1&utm_source=hs_email&utm_medium=email&utm_content=2&_hsenc=p2ANqtz--ISoa9FadatuUf8axqTnT-m6eqw-nxWQdQOyq007BpQqYF_FOVm1k-kwgV5Tb2ul2VXNrvakHdYFGnq9G1xg1kGcY4xw&_hsmi=2

That is the unsubscribe manage preferences page, correct? You have the query paramter d and also the _hsenc that I've mentioned above.

The _hsenc is what's used to compute the contact, it's the identifier; you'll manage user email preferences of X given the unique value of _hsenc. I don't know what hsenc stands for, but let's assume it's a lookup hash value that determinates the vid or user contact token or whatever you want to call it.

So, this is a bit too much of a hassle for such a basic stupid requirement, but given how horrible Hubspot is, I'm going to try to request the preferences page with the hsenc query parameter and extract the email from the html and then fetch the contact by email.

Let's see.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

This should do, even though it's a lot of hard work to get the Contact VID. Here's proof of concept so far, the DOM result provides the Contact vid:

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Unfortunately this is very costly and won't scale, each request takes a lot of time to process.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Following up on referrer_f_l

If you look above first comments, the dump of {{ contact }} is:

Why is referrer_f_l there? I looked into the custom properties we have on our side, there are plenty; Let's look at referrer_f_l:

What determinates if a custom property appears in the {{ contact }} exactly?

I'm now going to test and see if I can access {{ contact.referrer_f_l }}

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

The only difference I can see in the referrer_f_l, is that it have a default value, so created a test property with a default value and see if it's going to show in the {{contact}} dump.

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Hi @punkbit, just as a quick heads up our support team that monitors these forums aims to respond in under 2 business days. Luckily we have been able to work through our backlog pretty quickly and our response times are under 10 hours at the moment which is great. For more immediate assistance, Support can be reached by phone and aims to respond in under 3 minutes, or by webticket and aims to respond in under 24 hours (normally much faster than that).

For your particular issue, the reason you can't access the ID (vid), hutk or any other identifier on the contact object in an email is because vid and hutk are not contact properties. I looked into the thread you linked testing in my own account but it was not possible out of the box. Vid and hutk are unique identifiers that don't make much sense outside the context of the HubSpot database which is why it hasn't been built into HubSpot yet. I do see how it could be useful to surface as a contact property in your use-case, however. Other's share your sentiment, so I'd recommend upvoting and commenting on this idea.

One workaround I've heard of that could work in your case is creating a custom contact property called vid. You could then loop over all contacts in your portal using the get all contacts endpoint, then make a POST request to the update a contact endpoint to essentially copy the vid value to your newly created custom property, then use that how you'd like in your emails.You could run this job once for all your contacts, then create an active list of contacts who's vid values are blank (essentially all net new contacts would need to be updated), and just loop over that list for each subsequent job.

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Thanks for checking this post @Connor_Barley, I tried that too; based on my experience that custom properties also failed, I'm afraid; A simple use case that I tried a few hours ago (not working at the moment, just noticed you replied so, trying to put this out as quickly as possible so maybe can get another answer by tomorrow and save the day):

The email client got the following:

If I could get the contact.email address at least, like I pointed out above, I could create an md5 hash and create a service on our side, but Hubspot has screwed me up, it's almost beyond belief this is not accessible. There are so much documentation and articles promoting the API, so I've used it in our side. Previously reported major issues regarding data not reaching Hubspot, ended up having to use the Contacts API, my client paying for all the extra time and effort, reading the documentation etc; Not sure how I'm going to explain this to the client?

Can't even access the contact.email? Honestly Hubspot, this is unseen and it's not nice, the amount of money the service charges, promoting all the features, etc, but it's very limited. It's like going to a restaurant, ordering the food, getting it served but only allowed to stair at the food while hungry... This is not right! Has nothing to do with technology, but a very small minded decision, whoever decided and push that through and the team that didn't question it! That'll affect peoples business and lives. That's not acceptable!

I repeat; whoever that person is, who decided that VID, CONTACT ID or whatever is not useful for the Hubspot clients, needs to leave his small minded world and start practicing painting, maybe learn the guitar, or do anything that makes him think a bit, just a tiny little bit more creatively. Honestly! There's children creating API's with way better reach and accessibility, go wonder!

I'd like to remember that I need this to work directly in the Email Template, not in the WYSIWYG editor, I need to make sure that it exists every time the Hubspot Admin/Editor/User on our side have that in place.

I appreciate your effort, time and help, but hope you understand my point of view too.

Have to accept that this is not possible in Hubspot, that'll affect the business decision I'm sure.

I'm not happy!

Once again and it's never enough, thanks for replying to me @Connor_Barley and hope you don't take this personally; Technology should serve us, and this is not the case. I don't even have access to the contact.email? Not even the contact.email? What is that a security risk? Duh! So, the email is sent to a given email address and contact.email is not accessible, not even the contact.email? Please! Unbelievable... People will think I'm joking, honestly, no one is going to take me seriously

C'mon Hubspot team, you people can do way better, this is not nice, is it?! Unbelievable, what a waste of time

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Seems that is not possible to edit the subscriptions/unsubscribe page; so, what I'm planning to do now, is to use a headless browser and read the email value; it's a bit too much for such a basic requirement...

0 Upvotes
punkbit
Member

hubL Contact VID, UTK in the Email Template returns empty!

SOLVE

Also that doesn't work, because the url is not passed, not even with the replace filter

  <p>unsubcribe_hash: <a href="http://foobar?unsubcribe_hash={{ unsubscribe_link_all|replace('https://info.moo.la/hs/manage-preferences/unsubscribe-all-test?d=', '') }}"></a></p>
  <p>unsubcribe_url: <a href="http://foobar?unsubcribe_url={{ unsubscribe_link_all }}"></a></p>

The only contact prop that seems to be available according to earliest tests (see above), might be useful if I update it with the value of vid referrer_f_l; not sure if this is a custom property created in our side, asked the person who manages hubspot in our team, but why would that one be available no other, can we control which ones are available?

0 Upvotes