Tiktok Ads
Getting Started
To connect the TikTok Ads integration, follow these steps:
Sign In: A TikTok login window will appear. Enter your TikTok credentials associated with your TikTok Ads account.
Grant Permissions: Review the requested permissions, such as access to your ad accounts and campaigns. Click Allow to grant the necessary permissions.
Confirmation: After granting permissions, you'll be redirected back to HockeyStack
What Data Gets Tracked as Metadata
Field
Description
account_id_hashed
A hashed version of the account ID for secure storage.
type
The type of tracked data, such as paid-ads
.
date
The date of the ad activity, formatted as YYYY-MM-DD
.
id
A unique identifier for each data row, generated as an MD5 hash.
metadata
A JSON object containing detailed metadata about the campaign and ad.
account_id
The original account ID associated with the ad.
network
The advertising network, such as TikTok Ads
.
campaign_id
The unique ID of the campaign.
adgroup_id
The unique ID of the ad group.
ad_id
The unique ID of the ad.
campaign_name
The name of the campaign.
adgroup_name
The name of the ad group.
ad_name
The name of the ad.
utm_source
The source of the traffic, such as tiktok
.
utm_campaign
The campaign name, URL-encoded if necessary.
utm_medium
The medium of the traffic, such as paid
.
utm_content
Content-specific identifier for the campaign.
utm_term
The keyword associated with the campaign, if applicable.
impressions
The total number of impressions for the ad.
clicks
The total number of clicks for the ad.
cost
The total cost of the ad campaign in the specified currency.
currency
The currency in which the ad costs are measured (e.g., USD
).
High-Level Integration Flow
Validation:
We validate the
accessToken
to ensure it is associated with an advertiser account.The start of the integration process is logged for debugging and tracking purposes.
Ad Data Retrieval:
We fetch ad data using
getAds
and associated analytics usinggetReport
.Campaigns and line items are retrieved to ensure comprehensive data tracking.
Analytics and Data Processing:
Analytics data is merged with ad data using
mergeDataByAdId
.We use
formatData
to structure analytics and ad data into a unified format, including extracting UTM parameters.
Data Insertion:
Formatted data is stored in the metadata system using
insertToMetadata
.The account’s last processed date is updated to prevent redundant data processing.
Notes and Caveats
Token Handling:
The integration uses
accessToken
to authenticate requests to the TikTok Ads API.
Data Splitting:
Date ranges are split into 28-day increments to handle large datasets efficiently.
Last updated