Display Content Holder based on visitor location Print

  • Content Holder
  • 0

There may be instances where you want to display a Content Holder specifically to those browsing from Canada. This can easily be done using the Liquid global {{globals.site.countryCode}}.

In our example let's assume you have the following Content Holders called "US-Demographic" and "CA-Demographic" already set up with the custom content for each demographic region.

Next you need to put the Content Holder tags within a Liquid Logic {% IF ELSE -%} statement on a Web Page or Page Template like this example below.

{% if {{globals.site.countryCode}} == "CA" -%}
  {bb_contentholder source="CA-Demographic"}
{% else -%}
  {bb_contentholder source="US-Demographic"}
{% endif -%}

What's happening is the Liquid {% IF ELSE -%} statement pulls the visitors country code from browser meta data and checks to see if it matches "CA". If that returns "true" where the country code is equal "CA", then the content from the "CA-Demographic" Content Holder will render on the page. If the check returns "false" then the contents from US-Demographic will render on the page.

 


Was this answer helpful?

« Back

Powered by WHMCompleteSolution