Target API implementation
We implemented Target API in our server-side application (it handles the cross-sell module e.g. in checkout). We were not able to find a straightforward way to generate new visitor ids so we are relying on an ECID that is generated in storefront by Visitor ID Service implemented through Launch. As a result, we are able to test on visitors who had at least one page view before entering a test.
I have 2 questions:
1) Do you see any flaws in the implementation described below that could have unwanted consequences (e.g. double visitor counting)?
2) How can we generate a valid tntId, sessionID and ECID fully server-side?
1. Retrieve tntId and sessionID from the mbox cookie
Example:
session#2c8f32c1f6544dd5a15360f457f31043#1583507820|PC#2c8f32c1f6544dd5a15360f457f31043.26_0#1646751083
2. Retrieve marketingCloudVisitorId from the AMCV_xxx%40AdobeOrg (this is our org id cookie) cookie
Example:
1585540135%7CMCIDTS%7C18328%7CMCMID%7C61203425459504369920807087607432177946%7CMCAAMLH-1584104968%7C6%7CMCAAMB-1584104968%7C6G1ynYcLPuiQxYZrsz_pkqfLG9yMXBpb2zX5dvJdYQJzPXImdj0y%7CMCOPTOUT-1583507368s%7CNONE%7CMCSYNCSOP%7C411-18335%7CvVersion%7C4.4.0
3. Make a server call to Adobe Target (if any of the elements from 1 or 2 is not available, don’t make the call)
https://{client}.tt.omtrdc.net/rest/v1/delivery?client={client}&sessionId={{sessionID e.g. 2c8f32c1f6544dd5a15360f457f31043}}Body:
{
"context": {
"channel": "web",
"address" : {
"url" : "{{url}}"
}
},
"experienceCloud": {
"analytics": {
"logging": "client_side"
}
},
"id": {
"marketingCloudVisitorId" : "{{marketingCloudVisitorId e.g. 61203425459504369920807087607432177946}}",
"tntId": "{{tntId e.g. 2c8f32c1f6544dd5a15360f457f31043.26_0}}",
"thirdPartyId": "{{account id e.g. 0a9bc3d735014eb299dc057a8835e6ae}}",
"customerIds": [{
"id": "{{account id e.g. 0a9bc3d735014eb299dc057a8835e6ae}}",
"integrationCode" : "cust_attr_acctid",
"authenticatedState" : "authenticated"
},
"execute": {
"mboxes" : [
{
"name" : "CROSS-SELL-1722",
"index" : 1
}
]
}
}4. Retrieve tnta payload from the Target API response
Example tnta (execute → mboxes → analytics → payload → tnta): 265749:0:0|2,265749:0:0|32767,265749:0:0|1,266209:2:0|32767,266209:2:0|1
Example response:
{
"status": 200,
"requestId": "897f9a48-5654-4d21-a324-40d32b9833d2",
"client": "{{client}}",
"id": {
"tntId": "2c8f32c1f6544dd5a15360f457f31043.26_0",
"marketingCloudVisitorId": "61203425459504369920807087607432177946"
},
"edgeHost": "mboxedge37.tt.omtrdc.net",
"execute": {
"mboxes": [
{
"index": 1,
"name": "CROSS-SELL-1722",
"options": [
{
"content": {
"default": false
},
"type": "json",
"responseTokens": {
"experience.id": "0",
"activity.name": "{{activity name}}"
"activity.id": "265749",
"experience.name": "Experience A",
"geo.domainName": "{{domain name}}"
"offer.id": "596363"
}
}
],
"analytics": {
"payload": {
"pe": "tnt",
"tnta": "265749:0:0|2,265749:0:0|32767,265749:0:0|1,266209:2:0|32767,266209:2:0|1"
}
}
}
]
}
}5. If tnta exists, make a request to Data Insertion API (make sure we use the mid parameter)
https://{{client}}.sc.omtrdc.net/b/ss/{{report suide id}}/0/CODEVERSION?pe=tnt&tnta={{tnta payload e.g. 265749:0:0|2,265749:0:0|32767,265749:0:0|1,266209:2:0|32767,266209:2:0|1}}&mid={{marketingCloudVisitorId e.g. 61203425459504369920807087607432177946}}