Expand my Community achievements bar.

Why Is trackEvent Working in Web SDK Implementation?

Avatar

Level 2

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:

  • The event is being successfully logged in Adobe Target.
  • The userTheme parameter is being sent and correctly recognized by Target.
  • Debugging data confirms that the event is processed correctly:
{
  "eventType": "decisioning.propositionDisplay",
  "_experience": {
    "decisioning": {
      "propositions": [
        {"scope": "themePreference"}
      ],
      "propositionEventType": {
        "display": 1
      }
    }
  },
  "data": {
    "__adobe": {
      "target": {
        "userTheme": "dark"
      }
    }
  }
}

My Questions:

  1. Is trackEvent officially supported in the Web SDK, or is this behavior due to some fallback compatibility mechanism?
  2. Could this be a legacy feature of Adobe Target still supported for certain implementations?
  3. Should I refactor my code to use sendEvent for long-term compatibility?
  4. Is there any documentation that explains why trackEvent works under these circumstances?

Additional Information:

  • The mbox themePreference is already configured in Adobe Target.
  • The data passed (e.g., "userTheme": "dark") is visible in debugging tools.
  • I’m using Adobe Launch to deploy the Web SDK.

Thank you for your assistance in clarifying this behavior and guiding me on the best practices moving forward!

4 Replies

Avatar

Community Advisor

Hi @mahai ,

 

Yes, the trackEvent function works in the Adobe Target Platform Web SDKIt can be used to track conversion events, such as purchases and non-purchases. 
 
  • The Platform Web SDK can be used to track conversion events in Adobe Target.
  • Some conversion events are automatically tracked and don't require configuration.
  • Other conversion events require code updates.
  • Purchase conversion events may need to be adjusted for best practice implementation.
Adobe Target is a personalization and testing platform that helps businesses deliver personalized experiences to their customers. It's part of the Adobe Experience Cloud.
 
You can refer below document.
 
Thanks.
Pradnya

Avatar

Level 9

@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.

Avatar

Level 2

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.

Avatar

Level 9

@mahai suggest to use target extension then provided event rather webSDK events