Can we push click event to profile scripts?

yogitab98285400

02-01-2019

I am trying to set profile cookies using profile scripts...

Scenario :

if (page.url.indexOf ("xx")  != -1)

{

"Click on CTA/button"

  user.setLocal('yy', "true");

Is it possible ? and how can this be done.

ryanr8

Accepted Solutions (1)

Accepted Solutions (1)

ryanr701

Employee

03-01-2019

yogitab98285400​,

Keep in mind that profile scripts run on the Target server-side. So they have no visibility to client-side events (things that happen in the browser) unless the browser makes a call to Target with some data about the event.

So if you want to run a profile script on a click event you have to add a getOffer() or trackEvent() function to the onclick. In the trackEvent you can pass any necessary info in as parameters of the request. Then in the profile script I would add logic that only runs the script when the specific request I'm looking for (click event) is seen. Take any of the applicable data and read/store/parse it as needed.

As an example. If this code was on my page:

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

My profile script can look for an mbox name of 'dataCapture' (or whatever you choose to name the mbox). Then it can read my param1 value and do something with it.

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

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

    return x;

}

The profile script value can then but used to create an audience rule.

Answers (0)