CMS Development

benji_thecroc
Contributeur | Partenaire solutions Gold
Contributeur | Partenaire solutions Gold

If statement to check list/contact membership status

Résolue

Hi,

 

In HubSpot you can create smart CTAs that display based on contact list membership.

 

I was wondering if/how this could be executed as an if statement within a HubL template. For example; if user is in contact list display this content else display something else.

 

Thanks,

Benji

0 Votes
1 Solution acceptée
benvanlooy
Solution
Contributeur de premier rang | Partenaire solutions Platinum
Contributeur de premier rang | Partenaire solutions Platinum

If statement to check list/contact membership status

Résolue

This is certainly possible.

 

You should use the hulb IF/Statements in combination with the Hubspot Develerop Info.

 

Therefor, visit your page while logged in and open Developer info - see if you can find properties that show the user is known or not.  (probably contact email or so).

 

You can use this value in your IF/Else statement 🙂

 

Developer Info:

https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages

 

IF/ELSE

https://designers.hubspot.com/docs/hubl/if-statements

 

Voir la solution dans l'envoi d'origine

7 Réponses
iliascarre
Participant | Partenaire solutions Platinum
Participant | Partenaire solutions Platinum

If statement to check list/contact membership status

Résolue

@adriancblack Sorry to keep pinging you but I wanted to let you know I found and posted a solution incase you needed it for anything: https://community.hubspot.com/t5/CMS-Development/Check-member-list-to-display-specific-content-in-a-...

sharonlicari
Gestionnaire de communauté
Gestionnaire de communauté

If statement to check list/contact membership status

Résolue

thank you for sharing @iliascarre 


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Votes
iliascarre
Participant | Partenaire solutions Platinum
Participant | Partenaire solutions Platinum

If statement to check list/contact membership status

Résolue

@adriancblack I got this working earlier but it does not seem to be working anymore for some reason. I can't get any of my tests to work. Do you have a quick way to test whether this logic is still working within the module? Any help would be appreciated. Thank you!

0 Votes
adriancblack
Participant | Partenaire solutions
Participant | Partenaire solutions

If statement to check list/contact membership status

Résolue

It's like this:

You can use a text field (module.list_id) to store the list id that you can get from the url of list. They look like this:

https://app.hubspot.com/contacts/PORTALID/lists/1323

So in the above case the list id is 1323. Then use the request_contact.list_memberships variable that stores a list of all lists the contact is in.

 

Code below:

 

{% if module.list_id in request_contact.list_memberships %}

{% cta guid="{{ module.cta_for_list }}" %}

{% else %}

{% cta guid="{{ module.cta_for_everyone_else }}" %}

{% endif %}
iliascarre
Participant | Partenaire solutions Platinum
Participant | Partenaire solutions Platinum

If statement to check list/contact membership status

Résolue

@adriancblack This is brilliant! Thank you! 

roisinkirby
Équipe de développement de HubSpot
Équipe de développement de HubSpot

If statement to check list/contact membership status

Résolue

Hey @benji_thecroc - great question! @benvanlooy do you know if this is possible?

0 Votes
benvanlooy
Solution
Contributeur de premier rang | Partenaire solutions Platinum
Contributeur de premier rang | Partenaire solutions Platinum

If statement to check list/contact membership status

Résolue

This is certainly possible.

 

You should use the hulb IF/Statements in combination with the Hubspot Develerop Info.

 

Therefor, visit your page while logged in and open Developer info - see if you can find properties that show the user is known or not.  (probably contact email or so).

 

You can use this value in your IF/Else statement 🙂

 

Developer Info:

https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages

 

IF/ELSE

https://designers.hubspot.com/docs/hubl/if-statements