• Créditos da HubSpot: Desbloqueie ferramentas poderosas para o crescimento

    Dúvidas?

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

LizBW
Participante

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 Solução aceita
dannio
Solução
Top colaborador(a) | Parceiro Diamante
Top colaborador(a) | Parceiro Diamante

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.

Exibir solução no post original

2 Respostas 2
dannio
Solução
Top colaborador(a) | Parceiro Diamante
Top colaborador(a) | Parceiro Diamante

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
Alunos da HubSpot
Alunos da HubSpot

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

 

Thank you,

Pam