Lead Capture Tools

LizBW
Participant

Making a Smart CTA button display based on page language rather than user's browser language

Résolue

Our website includes a header with CTA buttons for users to "Log In" or "Sign Up." Both of these buttons are Smart CTAs, with the labels translated into all of our site languages. 

 

By default HubSpot will show the language variations based on the user's browser language setting, but we would like to have it display based on the Page Language setting. 

 

I've been told by Support that it's possible to custom code a module to do this, but that's all they offered and we don't have any devs on our team. Has anyone else dealt with this and have advice to offer?

1 Solution acceptée
LPM
Solution
Contributeur de premier rang | Partenaire solutions Diamond
Contributeur de premier rang | Partenaire solutions Diamond

Making a Smart CTA button display based on page language rather than user's browser language

Résolue

You can obtain the current page language tag via:

content.language.languageTag

 

This will output something like 'en', 'en-us', 'de', 'fr', etc.

 

To make a conditional for it, you simply need to put it in an if statement like so:

{% if content.language.languageTag == 'en' %}
   {% cta guid="{{ module.en_cta_field }}" %}
{% elif content.language.languageTag == 'fr' %}
   {% cta guid="{{ module.fr_cta_field }}" %}
{% endif %}

 

So in your module, you just need to create the corresponding CTAs for each language and make conditionals for it to show on the right pages.

Voir la solution dans l'envoi d'origine

2 Réponses
LPM
Solution
Contributeur de premier rang | Partenaire solutions Diamond
Contributeur de premier rang | Partenaire solutions Diamond

Making a Smart CTA button display based on page language rather than user's browser language

Résolue

You can obtain the current page language tag via:

content.language.languageTag

 

This will output something like 'en', 'en-us', 'de', 'fr', etc.

 

To make a conditional for it, you simply need to put it in an if statement like so:

{% if content.language.languageTag == 'en' %}
   {% cta guid="{{ module.en_cta_field }}" %}
{% elif content.language.languageTag == 'fr' %}
   {% cta guid="{{ module.fr_cta_field }}" %}
{% endif %}

 

So in your module, you just need to create the corresponding CTAs for each language and make conditionals for it to show on the right pages.

PamCotton
Gestionnaire de communauté
Gestionnaire de communauté

Making a Smart CTA button display based on page language rather than user's browser language

Résolue

Hello @LizBW , I would like to invite some of our top experts to share their ideas @danmoyle @LPM any recommendations to @LizBW?

 

Thank you,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


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