While it's recommended to use the built-in Trigger configurations we offer in the app, in some cases, you may want further customizations for when to trigger a Feedback Campaign. In this article, we'll show an example of how to trigger your Feedback Campaigns using code.

When setting up a Feedback campaign you have the option of using manual triggers. This means you can have your campaign triggered by any custom event on your website.

This can be when your visitor clicks a button or comes from a certain source - or any other event you need.

To trigger a campaign, you can call a simple function. You can call the function as part of your Mouseflow tracking code or add it as a stand-alone script. Here's an example of the function as a standalone script:

<script type="text/javascript"> 
window._mfq = window._mfq || [];
window._mfq.push(['activateFeedback', '{FEEDBACK-ID}']);
</script>

You can apply custom logic to the trigger event for your feedback campaign.

Here's an example of a script that wraps the feedback campaign trigger in a time delay. In this example, the delay is set to 60 seconds but can be changed for your purposes:

<script type="text/javascript">
var delayInMilliseconds = 60000; //60 second
setTimeout(function() {
window._mfq = window._mfq || [];
window._mfq.push(['activateFeedback', 'FEEDBACK-ID']);}, delayInMilliseconds);
</script>

Note: Replace the placeholder {FEEDBACK-ID} with the ID of the campaign in question. This ID is visible when you select the manual trigger and can also be seen in the URL of the campaign.

Note 2: Triggering a campaign manually will not override any other limitations in the campaign, like page rules.

Did this answer your question?