How do I use GTM as a trigger?
This article will explain how you can use a custom HTML tag so you can use GTM as a trigger. GTM triggers can be helpful if you want to use complex conditions to trigger your form on your page.
Note that the deployment script must be loaded beforehand, more information on where you can find this is explained in this article.
To trigger your form based on your own conditions in GTM, it is important that:
The GTM tag must add a JavaScript variable to the page where you want the form to be loaded;
This variable must also be in the conditions of the form deployment;
Pastease.forceParse()
must be called in the tag to evaluate the conditions again.
<script>
try {
var proActiveMopTrigger = 'triggered';
Pastease.forceParse();
}catch(err){
console.warn('Pastease could not parse. Please check if Pastease was loaded on the page.')
}
</script>
The triggering for this example is a click on a link that contains ‘about’ in the URL. If, in this example, the about section is clicked, the tag adds the variable to the page:
The script evaluates again, because this JS variable matches with what is set in the deployment, and the survey will show.
The deployment settings for the survey should be set to pro-active (such that it appears as a pop-up and it only shows once) and it should contain a check for the JS variable with the corresponding value (in the example code this is: proActiveMopTrigger contains triggered).