Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Can we push click event to profile scripts?

yogitab98285400
Level 1
Level 1

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

1 Accepted Solution
ryanr701
Correct answer by
Employee
Employee

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.

View solution in original post

1 Reply
ryanr701
Correct answer by
Employee
Employee

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.

View solution in original post