Adding custom variables to form links in WhatsApp
- Knowledge base
- Analytics
- General information about analytics
- Adding custom variables to form links in WhatsApp
With custom variables you can customize the link that will be created when clients click on WhatsApp in our widget.
How to create custom variables?
To create your own custom variables, go to Settings > Web Analytics and enable WhatsApp requests tracking. After that, you need to specify the variables in the welcome text.
To add your own variable, specify it in the format %{Name}, where Name is any arbitrary name. The number of variables is not limited.
After saving the text, the variable will be added.
How to set up the widget?
On the site where the widget is installed, you need to add a script. This script will allow the widget to work with the created custom variables:
document.addEventListener('initialize_widget', () => {
const chat24 = document.querySelector('#chat24-root chat-24')
chat24.setCustomMessageParams({
paramName: 'Text of paramName',
...
})
})
There are 3 methods available:
-
setCustomMessageParams(params: Record<string, string>)
– allows to fill all created parameters with one call. -
setCustomMessageByKey(key: string, text: string)
– allows to fill in a specific parameter. -
removeCustomMessageByKey(key: string)
– allows you to remove the parameter from the widget settings.