Site intercept research triggered on a Click event

Try OnCue Free

No credit card needed

OnCue’s sampling capabilities are very powerful and none are more powerful than the JavaScript sample trait.  It provides the ability to monitor for events to take place in your sites web pages that will dictate whether a site intercept will run for a particular user.  This kind of site intercept can be particularly helpful for getting customer experience feedback on a section of a site or a site process.  Because this is one of those few places in OnCue where you need to write some code it is recommended that you have a modicum of JavaScript skill and with the following examples some simple JQuery understanding.

Triggering Site Intercept based upon an On Click Event

The code below is a single line of code that will look for a particular element in a web page to be clicked and will make the JavaScript sample trait true.

OnCue.$("#lga img").one("click", __ON_TRAIT_MATCH__);

The $(“”) is a jQuery function that lets you look for certain elements within the web page.  It is the most used of all jQuery functions and can be quite powerful.  I won’t go into a full blow explanation of jQuery selectors but here is a link to the api reference and another to a simple jQuery Primer.   The above example is finding the image tag that has and ID of #lga and hooking its “click” event.   In this case we are using the Google Logo on the google home page as the example.

You can also define different events other than “click” to trigger a site intercept for your customer experience research.  We have only tested the code using “click” but feel free to try to monitor for other events such as mouseover or onkeypress.  Just make sure the element you are monitoring uses that event. Here is a list of HTML events.

Here are a few other examples:

Example 2:

OnCue.$("a[title='HIGH PERFORMANCE']").one("click", __ON_TRAIT_MATCH__);

Identifies an anchor tag that has the title HIGH PERFORMANCE. This example was actually a menu item

Example 3:

OnCue.$("a[data-sublist-translation='select_brand']").one("click", __ON_TRAIT_MATCH__);

Identifies an anchor tag with an attribute that had select_brand as the value. This element triggered a drop down and did not navigate between pages.

Important things to remember when using JavaScript Traits

site intercept in new browser window

  1. If the click event causes a navigation you have to open your research using a “New Browser Window” under the Behavior tab.
  2. If the click does not cause a navigation you can use an “On Page Dialog” or you can use an Opt-in Dialog but if you choose to use an Opt-in Dialog you need to make it part of the same Sample Group.  Rule of thumb is that all traits in a Sample Group must be true for research to be triggered.  Two or more Sample Groups are treated as either situations.  If one Sample Group is true the research can be triggered.

The Code if you don’t want to copy it from above.

Please direct any questions to OnCue support.

Take charge of your customer experience research!

Use the best tools and never wait on IT again