Fetch Creative Token
Retrieve creative token before sending events
Use FetchToken to retrieve the user’s creative token information if you didn’t call RegisterUser.
This step is required before sending any in-app events if the creative token wasn’t already fetched during registration.
import { FetchToken } from "audiencelab_nodejs_sdk";const fetchUserCreativeTokenEvent = new FetchToken(client, userData);
await fetchUserCreativeTokenEvent
.send()
.then((response) => {
userData.setUserCreativeTokenInfo(response);
})
.catch((error) => {
console.error("Error fetching creative token:", error);
});After this call:
- The user_data object is updated with the creative token info
- You're ready to send events like retention, purchase, and ad view
If you already called RegisterUser, you don't need to call FetchToken again.
When to call this?
Call FetchToken only if
- The user was previously registered, but you didn’t fetch the creative token yet
- You need to refresh/update the creative token