Expand my Community achievements bar.

SOLVED

How to track clicks using web sdk

Avatar

Level 2

I am trying to manually track clicks on a website using adobe Target via Web SDK, Im used to use getOffer/Apply offer for custom click tracking, Im aware this does not work anymore on web SDK, but looking up for the documentation, it says that you can use adobe.target.sendNotifications() but is not working either, it throws an error saying that sendNotifications is not defined. How can I send a custom event then?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Yes, in the code I provided the if statement is empty: 

if (result.propositions) {
      // Manually render propositions and send "display" event
    }


So if you change it to the following then you'd see the response from Target output to console

if (result.propositions) {
      console.log(result.propositions)
    }

 
The idea with this custom mbox approach is that you write code that handles everything in the result.propositions response i.e., parse through the response and render the offer content in the appropriate location. If you don't want to do any of this manual work then you could use the default '__view__'  mbox and set up your activity via the Visual Editor Composer; the Web SDK would then take care of automatically rendering the response from Target 

View solution in original post

12 Replies

Avatar

Employee Advisor

This document gives a good overview of how at.js functionality translates to Web SDK, including event tracking

Avatar

Level 2

Thank you @alexbishop  
I assume, the correct way would be using the alloy sendevent function, but how the goal of 'View an mbox' from Adobe Target can be fullfilled with the sendevent funtion, woul this be correct?

alloy ( "sendEvent" , {
  renderDecisions : true,
  data : {
    __adobe : {
      target : {      
        "track": {
          "scopes": "mbox-custom-name",
          "type": "click"
        }
      }
    }
  }
} ) ;

Avatar

Employee Advisor

You could use the following if you've implemented Web SDK with XDM 

alloy("sendEvent", {
    "type": "decisioning.propositionDisplay",
    "xdm": {
        "_experience": {
            "decisioning": {
                "propositions": [{
                    "scope": "xdmClick" // Or any mbox/location name you want to use in Adobe Target
                }]
            }
        }
    }
});

Or have you implemented Web SDK more recently and are solely using the data.__adobe.target approach?

Avatar

Level 2

Hi @alexbishop 

We are using xdm on the implementation, so with the code you provided, it would work as 'view an mbox' metric on targer (xdmClick)??

Avatar

Employee Advisor

Yes, exactly, the Metric configuration would look like this

alexbishop_0-1716795007953.png

 

Avatar

Level 2

Thanks for the answer, would that code trigger any activity set with the trigger 'xdmClick' as the triggering location mbox?

Avatar

Employee Advisor

The default behaviour is that the metric will increment against all of the activities the user is qualified for, which use that same success metric. If you want to adjust that default behaviour, there is some more useful information here, in terms of advanced settings like creating dependencies etc, in case you haven't already seen it. 

Avatar

Level 2

Hi @alexbishop 
What I meant, is if that code that is used to count conversions, is the same for triggering activities using a custom mbox (what used to be the getOffer -> applyOffer function) for a configuration like this:

jmgx_0-1718086822773.png

 

Avatar

Employee Advisor

Ah ok, for custom mbox activities you just need to pass the name of the mbox in the decisionScopes array. For example:

alloy("sendEvent", {
    "xdm": {},
    "decisionScopes": ['activityOneMbox', 'activityTwoMbox']
  }).then(function(result) {
    if (result.propositions) {
      // Manually render propositions and send "display" event
    }
  });

You'd likely also be sending some additional attributes as part of the xdm object, so the example above is just to illustrate the decisionScopes aspect. There's a full explanation here

Avatar

Level 2

Following with mi last question, I tried to configure an activity based on the custom mbox like this:

jmgx_0-1718352551580.png

and then, executing the code you provided on console:

jmgx_1-1718352603276.png

Even when the preview on console is showing the activity and its code, no code is being executed on the page, am I doing something wrong?

jmgx_2-1718352699384.png
jmgx_3-1718352731117.png

 

Thank you for your help



Avatar

Correct answer by
Employee Advisor

Yes, in the code I provided the if statement is empty: 

if (result.propositions) {
      // Manually render propositions and send "display" event
    }


So if you change it to the following then you'd see the response from Target output to console

if (result.propositions) {
      console.log(result.propositions)
    }

 
The idea with this custom mbox approach is that you write code that handles everything in the result.propositions response i.e., parse through the response and render the offer content in the appropriate location. If you don't want to do any of this manual work then you could use the default '__view__'  mbox and set up your activity via the Visual Editor Composer; the Web SDK would then take care of automatically rendering the response from Target 

Avatar

Level 1

Hello @alexbishop, based on this example that you gave:

 

alloy("sendEvent", {
"type": "decisioning.propositionDisplay",
"xdm": {
"_experience": {
"decisioning": {
"propositions": [{
"scope": "xdmClick" // Or any mbox/location name you want to use in Adobe Target
}]
}
}
}
});

You know if it's possible to send information to populate the detailed report?
Thanks