Are you interested in firing a Nudge based on a particular element is selected on-site? This help article serves as a step-by-step guide to help you set up this powerful targeting technique.
1. Locate the element on the page you would like to target
Once you have located the element, your next step is to get the CSS Selector for it.
A CSS selector is a way for browsers to find elements on a page. It looks something like:
#link-8j8dwhmrmrq > div
You can obtain it by either:
A) Using your browser's Dev Tools, right-click on the element and choose “Inspect Element”. Next, right click on the element in Elements view, choose Copy > Copy Selector.
B) Use a Chrome extension like SelectorGadget
2. Append JavaScript to your Qualaroo snippet
Now that we have the CSS Selector for the element, we are going to use some JavaScript to attach a click event to it that calls the Qualaroo API and sets a Custom Property.
This code will set the custom property 'event': 'Clicked My Element' when the element with the CSS Selector #link-8j8dwhmrmrq > div is clicked.
Append it after your Qualaroo snippet or on the pages where the element is present. Please see below for an example snippet that you can adjust to your specifications:
<script>
var e = document.querySelector('#link-8j8dwhmrmrq > div');
if(e){
e.onclick = function(){
window._kiq.push(['set', { 'event': 'Clicked My Element' }]);
};
}
</script>
Set Up Targeting
Now that we set up the JavaScript to set the Custom Property, we need to target the survey.
We recommend to only target specific pages where the element is visible. In addition, keep all other targeting options to make sure the survey fires when the element is clicked.
Select the option “When passed custom property is matched” within your Targeting Dashboard for the intended survey. Selecting this option will open a text field, where you can enter your unique text. Please see below for example text:
event = "Clicked My Element"
We hope this information has been helpful. Please feel free to reach out to support@qualaroo.com if you have any questions or need anything else!
Comments
0 comments
Article is closed for comments.