When using the Treasure AI JavaScript SDK to track user behavior on your websites, you can integrate collected information into other marketing or social media platforms as conversion events to improve measurement and to optimize your advertising campaigns on those platforms. This article describes how to collect common third-party tags and other tracking information.
- Basic knowledge of JavaScript and HTML.
- Knowledge about the platform tags you want to collect.
- Treasure AI JavaScript SDK version 4.1 or above. The following instruction assumes that you have already initialized the Treasure AI JS SDK in a
tdvariable, and that you are ready to send events to the Treasure Console.
The collectTags API automatically collects cookies and URL parameters from third-party advertising platforms (Meta, Google Ads, Yahoo! Ads, etc.) and sends them along with tracking events.
Collected tags are stored in the $global object and sent together with all tracking payloads. This enables efficient collection of tracking information required for conversion APIs across various advertising platforms.
// Initialize Treasure AI JS SDK
var td = new Treasure({
database: 'your_database',
writeKey: 'your_write_key'
});
// Declare to collect Meta Click ID
td.collectTags({
vendors: ['meta']
});
// Tag values will be sent together with the page view event
td.trackPageview('page_views');// Specify cookie names and URL parameter names directly
td.collectTags({
cookies: ['_custom_cookie', '_another_cookie'],
params: ['custom_param', 'tracking_id']
});// Collect from multiple platforms at once
td.collectTags({
vendors: ['meta', 'google_ga', 'google_mp', 'x', 'tiktok']
});Behind the scenes, collectTags collects platform-specific cookies and URL parameters (e.g., fbclid parameter, _fbc and _fbp cookies for Meta) and stores them in the $global object, which is sent together with any tracking payload.
| Vendor Name | Platform | Primary Use Case |
|---|---|---|
meta | Meta (Facebook/Instagram) | Facebook advertising tracking |
google_ads | Google Ads | Google advertising click tracking |
google_ga | Google Analytics | Google Analytics user identification |
google_mp | Google Marketing Platform | Google Marketing Platform |
instagram | Instagram advertising & user tracking | |
yahoojp_ads | Yahoo! JAPAN Ads | Yahoo! Ads & LINE Yahoo! |
line | LINE | LINE advertising tracking |
x | X (formerly Twitter) | X advertising click tracking |
pinterest | Pinterest advertising & EPIK | |
snapchat | Snapchat | Snapchat campaign identification |
tiktok | TikTok | TikTok user tracking |
marketo | Marketo | Marketo lead tracking |
tealium | Tealium | Enterprise TMS |
Parameters:
configs (Object, optional): Configuration object containing collection settings
vendors: Array of supported vendor namescookies: Array of specific cookie names to collectparams: Array of specific URL parameter names to collect
options (Object, optional): Additional configuration object
gclPrefix: Custom cookie prefix for Google Marketing Platform (default:'_gcl')
Returns: void
Examples:
// Collect from multiple platforms
td.collectTags({
vendors: ['meta', 'google_ga', 'google_mp'],
cookies: ['_custom_cookie'],
params: ['custom_param']
}, {
gclPrefix: '_custom_gcl'
});Collected Data:
- Cookies:
_fbp(Facebook Browser Pixel),_fbc(Facebook Click) - URL Parameters:
fbclid(Facebook Click ID) - Use Case: Facebook/Instagram advertising effectiveness measurement, Meta Conversion API integration
Collected Data:
- URL Parameters:
gclid(Google Click ID),wbraid(Web Conversion Browser ID) - Use Case: Google Ads click tracking, iOS 14.5+ privacy compliance
Collected Data:
- Cookies:
_ga(Google Analytics Client ID) - Use Case: User identification between Google Analytics and Treasure Data CDP
Collected Data:
- Cookies: All cookies starting with
_gclprefix (dynamic collection) - Use Case: Google Marketing Platform (formerly DoubleClick) Conversion Linker
Collected Data:
- Cookies:
shbts(Browser Timestamp),shbid(Browser ID),ds_user_id(User ID),ig_did(Device ID) - Use Case: Instagram advertising effectiveness measurement, logged-in user tracking
Collected Data:
- Cookies:
_ycl_yjad,_yjr_yjad,_yjsu_yjad,_ly_c,_ly_r,_ly_su - URL Parameters:
yclid,yj_r,ly_c - Use Case: Yahoo! search ads, display ads, LINE Yahoo! integrated analysis
Collected Data:
- Cookies:
__lt__cid(Customer ID),__lt__sid(Session ID) - URL Parameters:
ldtag_cl(Click ID) - Use Case: LINE advertising effectiveness measurement, LINE Tag tracking
Collected Data:
- Cookies:
_twclid(Twitter Click ID Cookie) - URL Parameters:
twclid(Twitter Click ID Parameter) - Use Case: X advertising click tracking, conversion measurement
Collected Data:
- Cookies:
_epik(Enhanced Partner Information Kit Cookie) - URL Parameters:
epik(Enhanced Partner Information Kit Parameter) - Use Case: Pinterest advertising effectiveness measurement, Enhanced Matching
Collected Data:
- URL Parameters:
ScCid(Snapchat Campaign ID) - Use Case: Snapchat campaign identification, advertising effectiveness measurement
Collected Data:
- Cookies:
_ttp(TikTok Tracking Parameter) - Use Case: TikTok user tracking, advertising effectiveness measurement
Collected Data:
- Cookies:
_mkto_trk(Marketo Lead ID) - Use Case: Marketo lead tracking, marketing automation integration
Collected Data:
- Cookies:
utag_main(Universal Tag Main Cookie) - Use Case: Enterprise Tag Management System, integrated data management
var td = new Treasure({
database: 'marketing_data',
writeKey: 'your_write_key'
});
// Bulk collection from major platforms
td.collectTags({
vendors: ['meta', 'google_ads', 'google_ga', 'x', 'tiktok']
});
td.trackPageview('page_views');
td.trackEvent('conversions', { action: 'purchase', amount: 100 });// Japanese market focus
td.collectTags({
vendors: ['yahoojp_ads', 'line', 'meta', 'google_ga']
});
// Western market focus
td.collectTags({
vendors: ['meta', 'google_ads', 'x', 'pinterest', 'snapchat']
});// Social media platforms
td.collectTags({
vendors: ['tiktok', 'snapchat', 'instagram', 'x']
});- Ensure compliance with each platform's privacy policies
- Proper consent collection is required for GDPR, CCPA, and other regulations
- Browser privacy settings and ad blockers may affect data collection
nullvalues are set when cookies or URL parameters don't exist- Some platforms require corresponding Pixel or Tag implementations
- Cross-site tracking restrictions may prevent some cookie collection
- Consider initialization time impact when specifying many vendors
- Recommend specifying only necessary platforms for your use case
- Monitor payload size when collecting extensive tag data
Social Media Focused Tracking