Can Profile Scripts be used to build up audiences based on click event?

Explore this article to learn how to use Profile Scripts to track click events on the page and be able to build audiences based on the collected data in Adobe Target.

Description description

Environment

Adobe Target

Issue/Symptoms

How to use Profile Scripts to track click events on the page and be able to build audiences based on the collected data.

Resolution resolution

Solution steps
Keep in mind that Profile Scripts run on Target server-side, this means they have no visibility of client-side events (events that happen in the user browser) unless the browser makes a call to Target passing the relevant data.

  1. So if you want to run a profile script on a click event you have to add a getOffer() or trackEvent() function to listen to the onclick event.
  2. In the trackEvent() you can pass any necessary data as parameters within the request.
  3. Then in the profile script you should add logic that only runs the script when the specific request being tracked (onclick event) is executed.
  4. Take any of the applicable data and read/store/parse it as needed.

As an example, by using this code on a webpage:

<a href="#" onclick="adobe.target.trackEvent({mbox:'dataCapture', params:{'param1':'value1'}});">click here</a>

The example profile script can look for an mbox named dataCapture (or any other mbox name you have defined), then it could read my param1 value for further utilization, e.g.:

if (mbox.name == 'dataCapture') {

    var x = mbox.param('param1'); 

    return x; 

}

The profile script value (param1) can then be used to create an audience rule.

Please note the code above is only a sample, make sure your code logic surfaces the requirements of your use case.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f