Lead Capture Tools

LizBW
Participant

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

SOLVE

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 Accepted solution
LPM
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

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

SOLVE

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.

View solution in original post

2 Replies 2
LPM
Solution
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

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

SOLVE

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
Community Manager
Community Manager

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

SOLVE

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 !