- TLC Home Home
- Discussions & Ideas Discussions & Ideas
- Product Guides Product Guides
- Knowledge Base Knowledge Base
- Developer Docs Developer Docs
- Education Education
- Blog Blog
- Support Desk Support Desk
This article describes how to use the HTTP API - Advanced data source to create an HTTP endpoint to collect real-time event data with support for flattening complex objects.
In this article:
The HTTP API - Advanced data source is a generic data source that can conditionally parse incoming request bodies. This data source offers an HTTP endpoint to collect real-time event data with support for flattening complex objects. The endpoint is flexible and can be implemented as a tracking pixel in a web page or as a JSON API in your custom application.
This data source is similar to the HTTP API data source, but with additional support for complex JSON objects. Events sent using HTTP POST with a complex JSON object will be flattened as follows:
"alpha" : { "beta" : true }
"alpha_beta" : true
Use this data source type when you need to send data in real-time and cannot modify the request to meet format requirements for the standard Tealium Collect endpoint.
The HTTP API - Advanced data source HTTP endpoint supports multiple events in a single request. These events are called batched events. For batched events, you receive one response code based on the status of all records. If a single record/event fails, only that event fails, the rest is processed.
The HTTP API - Advanced data source supports both the GET and POST methods.
Use the following endpoint to access the HTTP API - Advanced data source:
https://collect.tealiumiq.com/integration/event/ACCOUNT/PROFILE/DATA_SOURCE_KEY?tealium_trace_id=TRACEID
The following default parameters are supported in each request:
Parameter | Description |
---|---|
tealium_event |
(Optional) The name of the event. |
tealium_trace_id |
(Optional) For use with Trace. Must be set as a query string parameter. |
tealium_visitor_id |
(Optional) For use with Tealium AudienceStream. If |
This section provides guidance on how to add the HTTP API - Advanced data source and create a webhook.
Add the HTTP API - Advanced data source before proceeding, then copy the generated endpoint for use in an external system.
Related: How to Add a Data Source
Response Code | DESCRIPTION |
---|---|
HTTP 204 |
Request Successful |
HTTP 400 |
Malformed JSON request |
HTTP 404 |
The HTTP API - Advanced Incoming Webhook is useful when you want to send an HTTP API Advanced call using Javascript, bash scripting or curl.
By default a JSON array will be treated as several events; so:
[ { "Id": "1", "Detail": { "Name": "Event A" } }, { "Id": "2", "Detail": { "Name": "Event B" } } ]
Will be transformed into several events:
// First Event { "Id": "1", "detail_name": "Event A" } // Second Event { "Id": "2", "detail_name": "Event B" }
{ "events": [
{ "id": "1", "name": "Event A" }, { "id": "2", "name": "Event B" }, { "id": "3", "name": "Event C" } ] }
{ "events": [ "{\"id\":\"1\",\"name\":\"Event A\"}", "{\"id\":\"2\",\"name\":\"Event B\"}", "{\"id\":\"3\",\"name\":\"Event C\"}" ] }
This section provides examples of input code and the resulting (flattened) output for complex objects.
The following purchase event example shows how client-side e-commerce events with complex objects get flattened.
{ "ecommerce": {
"event": "purchase", "purchase": { "customer": { "id": "8237572", "email": "john.smith@example.com", "city": "San Diego", "state": "CA", "country": "United States" }, "order": { "id": "ORD123456", "store": "mobile web", "subtotal": "2524.00", "total": "2549.00" }, "product": { "name": ["Product One", "Product Two"], "id": ["PROD123","PROD456"], "price": ["12.00","1250.00"], "brand": ["Ralph Lauren","Lucky"], "category": ["Apparel","Apparel"], "quantity": [1,1] } } } }
After flattening, the purchase event becomes:
{
"ecommerce_event": "purchase", "ecommerce_purchase_customer_id": "8237572", "ecommerce_purchase_customer_email": "john.smith@example.com", "ecommerce_purchase_customer_city": "San Diego", "ecommerce_purchase_customer_state": "CA", "ecommerce_purchase_customer_country": "United States", "ecommerce_purchase_order_id": "ORD123456", "ecommerce_purchase_order_store": "mobile web", "ecommerce_purchase_order_subtotal": "2524.00", "ecommerce_purchase_order_total": "2549.00", "ecommerce_purchase_product_name": ["Product One", "Product Two"], "ecommerce_purchase_product_id": ["PROD123","PROD456"], "ecommerce_purchase_product_price": ["12.00","1250.00"] "ecommerce_purchase_product_brand": ["Ralph Lauren","Lucky"], "ecommerce_purchase_product_category": ["Apparel","Apparel"], "ecommerce_purchase_product_quantity": [1,1] }
Copyright All Rights Reserved © 2008-2022