Lead Capture Tools

LizBW
参加者

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

解決

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件の承認済みベストアンサー
LPM
解決策
トップ投稿者 | Diamond Partner
トップ投稿者 | Diamond Partner

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

解決

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.

元の投稿で解決策を見る

2件の返信
LPM
解決策
トップ投稿者 | Diamond Partner
トップ投稿者 | Diamond Partner

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

解決

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
コミュニティーマネージャー
コミュニティーマネージャー

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

解決

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 !