Chord Commerce Data Platform
Data Activations
Audiences API
19min
overview chord's audiences api allows you to access audiences, along with associated audience attributes, directly via api looking for information on how to activate an audience to ninetailed? check out our documentation here ! use cases use the audience "products abandoned," which has every visitor's top products last viewed but not yet purchased, to customize the experience on your website for repeat visitors by featuring these users' top products for enhanced personalization and conversion opportunity create an audience with personalized user attributes, such as new vs returning visitor, last campaign seen, and more, to test different landing page customizations on your website getting started data destination once your account has the audiences api enabled, the "dynamic audiences api" data destination will be available in data activations audiences you can use a pre built audience or create a custom audience you want to activate via the audiences api the audience must use the cdp blended user id, which is derived from the chord data models and contains the cdp user id, if one exists, else the cdp anonymous id this use case is particularly useful when mixing users who may or may not have a known cdp user id by using the cdp blended user id, audiences can be created for both users and visitors using the same id, also allowing us to aggregate all audiences at the blended user id level in the api activations sync select a source and destination once your destination is enabled and you have the audience you'd like to use, you'll create a sync in activations using our sync ui, we must create a new sync that connects a custom audience as the source, the dynamic audiences api as the destination, and the object as {name} audiences , with the object being pre configured in the provisioning process sync behavior sync behaviors dictate the types of change that should be applied to your data when a sync finds a matching (or not) record in a source and a destination we want to use the "mirror" option, which will perform the following behaviors for records in the destination create this will add new users in a given audience update this will change values for users in a given audience for example, if data like top products change for a given user in an audience, this behavior will update that record in the destination delete this will delete values for users no longer in a given audience sync key sync keys will dictate how to associate data in the source with the destination both the source and destination need to provide a single, unique per record, identifying field the identifiers will be used to look for matches when a match is found, or not found, we can use your selected sync behavior to decide what to do your sync key can be any unique identifier, like a user id, an email address, etc however, we recommend using the cdp blended user id provided by chord to provide user consistency across all datasets, allowing for the best matching in the destination field mappings once you've defined how data is related between your source and destination, the next step is to determine what properties should be updated the field mapping step lets you specify how fields should be mapped from your source model to the destination object's fields we start by assigning our unique user identifier anonymous current cdp blended user id will become our pk (primary key) we can then set up the sk (sort key) it is important to ensure that this value reflects the name of the audience being synced you can easily obtain that value by choosing sync metadata > source name , which will dynamically populate the name applied to your audience you should end up with the following data field (optional) the destination supports flexible schemas, allowing you to send any data and define custom names for destination fields make sure to send the content to a data destination field you must use liquid templating https //shopify github io/liquid/basics/introduction to perform last mile transformations on your source data for example, if your audience contains an anonymous id , user id , and a list of products and you'd like to append these data components for use via the api, the following mapping will create a data attribute in the api response { "anonymous id" {{ record\['anonymous id'] }}, "user id" {{ record\['user id'] }}, "products" {{ record\['products'] | raw }} } any column can be added to this data attribute, making these supplemntary values will be available via api sync schedule like any other sync on our data activations page, it can be scheduled to run at regular intervals sync results the chord platform will display the sync results as usual how to make requests to the audiences api prerequisites an api key provided by chord, to be used as a bearer token if you have not received your api key, please reach out to help\@chord co a unique user identifier that is being used as the pk in your sync it should be included in the request headers depending on your sync field mapping, it could be an email address, an anonymous id, a user id, etc chord recommends using the cdp blended user id as the primary key request example when cdp blended user id is being used as the pk in your sync curl x get \\ h "authorization bearer your bearer token" \\ h "chord user id 7496fd47cc30 143c 4279 6e6e8a7a" \\ https //analytics api chord co/audiences response example when blended user id is being used a the pk in your sync { "user" "7496fd47cc30 143c 4279 6e6e8a7a", "audiences" \[ { "name" "audience cart abandoned", "data" { "unique session count" 2, "unique session with completed order count" 0, "user email" "", "unique session added product count" 1 } } ] } request sample below are example requests, but this will depend on your server side framework audiences api should always be called server side typescript const userid string | null = null; // assuming that userid is not known const anonymousid string = '7496fd47cc30 143c 4279 6e6e8a7a'; // use the nullish coalescing operator (??) to fall back to anonymousid // if userid is null or undefined const blendeduserid string = userid ?? anonymousid; const url string = 'https //analytics api chord co/audiences'; const headers headersinit = { 'authorization' 'bearer your bearer token', 'chord user id' blendeduserid }; async function fetchdata() { try { const response = await fetch(url, { method 'get', headers headers }); if (!response ok) { throw new error(`http error! status ${response status}`); } const data = await response json(); console log(data); // handle the response data here } catch (error) { console error('error ', error); // handle errors here } } fetchdata(); troubleshooting and faqs question how do i get access to audiences api? please reach out to help\@chord co or your account executive for more information about or access to this feature question can i leverage chord's audiences api to activate audiences on other platforms? yes! you can leverage chord's audiences api to send audiences to ninetailed if you need assistance or have questions about other platforms, please reach out to us at help\@chord co