I recently implemented a custom script for Adobe Target using the trackEvent API, despite using the Web SDK for my setup. Surprisingly, the script is working, and the trackEvent is successfully passing parameters to Adobe Target. I would like to understand why this is happening, given that sendEvent is the recommended method for Web SDK.
Here is the script I used:
<script> const osTheme = window.matchMedia("(prefers-color-scheme: dark)"); if (osTheme.matches) { adobe.target.trackEvent({ "mbox": "themePreference", "params": { "userTheme": "dark" } }); } else { adobe.target.trackEvent({ "mbox": "themePreference", "params": { "userTheme": "light" } }); } </script>
What I Observed:
{ "eventType": "decisioning.propositionDisplay", "_experience": { "decisioning": { "propositions": [ {"scope": "themePreference"} ], "propositionEventType": { "display": 1 } } }, "data": { "__adobe": { "target": { "userTheme": "dark" } } } }
My Questions:
Additional Information:
Thank you for your assistance in clarifying this behavior and guiding me on the best practices moving forward!
Views
Replies
Total Likes
Hi @mahai ,
Views
Replies
Total Likes
@mahai it seems you are not implementing track events using Target Extention via Adobe launce rather directly using custom script, I suggest moving the script to Target Extention implementation.
Views
Replies
Total Likes
Thank you, @RiteshYadav18. That's partially correct. We are indeed using the Web SDK extension.
What actually happened was that trackEvents was working because we were using a script in Launch that converted trackEvents to sendEvents. This was undocumented, hence my confusion.
Views
Replies
Total Likes
@mahai suggest to use target extension then provided event rather webSDK events
Views
Replies
Total Likes