Tick Tok API Conversion: Function For Sending Events

The below function can be used for sending the events to the TikTok pixel ad account for the conversion tracking

            sendEventData: function (data) {

                try {

                    var token = Configuration.get(‘TicktokPixel.Token’);

                    var apiResponse;

                    var url = ‘https://business-api.tiktok.com/open_api/v1.3/event/track/’;

                    var bodyObj = data;

                    var headers = {

                        ‘Access-Token’: token,

                        ‘Content-Type’: ‘application/json’,

                        ‘Accept’: ‘*/*’,

                        ‘Accept-Encoding’: ‘gzip, deflate, br’,

                        ‘Connection’: ‘keep-alive’

                    }

                    apiResponse = nlapiRequestURL(url, bodyObj, headers, null, “POST”);

                    return apiResponse

                } catch (err) {

                    return apiResponse

                }

            }

where

Token: The token generated from the TikTok ad account

bodyobj: data Payload including events and parameters

Leave a comment

Your email address will not be published. Required fields are marked *