Home > How to load one widget or another depending on variables

Categories: | | | |


(Last Updated On: August 8, 2018)

Most of our customers would choose which widget they want to install where, and install them accordingly on those pages. However, if you are running more of a complex operation, where you may want to detect some specific settings to determine which widgets to load, we can help with that!  In that case you may want to load one widget or another depending on different variables you can expose from your website. This article will show you how to do this.

In this example, we are not going to install any specific widgets, but we are going to determine which widget to load depending on which language the website is being shown on.  This is only a template, but the idea is to show how to load a widget or another, the conditions for the loading of one or another widget can be determined by you on the javascript, by using variables on your code.

 

 


With this example code, we are determining the language on the address bar (language=fr or language-en), and loading one widget or another accordingly using the switchWidgetId function. We are also setting a default widget to be loaded in case the language in the address bar doesn’t match either. Once you determine the variable on your website, you will be able to use this template to load your widgets.

You can also contact us on support@snapengage.com to discuss further or start a chat with us.

Did you find this article helpful?

Not HelpfulNeeds WorkSo-soHelpfulVery Helpful (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Published August 8, 2018