How to Trigger a Nudge When an Element Is Clicked
With Qualaroo, you can show a nudge when the user clicks on a page element.
This can help you to:
- Get feedback on specific elements.
- Learn about user reactions to new website features.
Here's what the triggered nudge will look like when a user clicks a button:
To trigger a nudge when an element is clicked:
Step 1: Locate the element on a page and copy the CSS selector. To do so,
-
Go to the page on which you want to trigger the nudge.
-
Right-click on the element and click Inspect.
-
Right-click on the highlighted HTML element in the Inspect window. Click on Copy > Copy selector.
Step 2: Append JavaScript to your Qualaroo snippet
-
Enter the custom property: 'event': 'Clicked My Element' to the element with the CSS Selector. Here, #newsubmit.
-
Append the following script before the </body> tag in your HTML code.
if(e){
e.onclick = function(){
console.log("clicked");
window._kiq.push(['set', { 'event': 'Clicked My Element' }]);
};
}
OR
if(e){
e.onclick = function(){
console.log("clicked");
window._kiq.push(['set', { 'event': 'Clicked My Element' }]);
};
}
This code will set the custom property 'event': 'Clicked My Element' when the element with the CSS Selector #newsubmit is clicked.
Step 3: Set up the targeting event
In the TARGETING section,
-
Click to expand Who and then expand the Advanced subsection.
-
Check the box next to “When passed custom property is matched” in the advanced targeting.
-
Enter “event = "Clicked My Element" in the textbox.
Your survey is ready for targeting.
And that's it! If you encounter any issues or have any questions, don't hesitate to reach out to our support team.