Skip to content
Last updated

Third Party Conversion Tags Collecting With JS SDK

When using the TD 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.

Prerequisites

  • Basic knowledge of JavaScript and HTML.
  • Knowledge about the platform tags you want to collect.
  • Treasure Data JavaScript SDK version 4.1 or above. The following instruction assume that you have already initialized the TD JS SDK in a td variable, and that you are are ready to send events to the TD Console.

Collecting Third-party Tags Using the collectTags Method

Third-party tags, such as a Meta Click ID, could be embedded in your website as cookies or request parameters when the user lands on your website via advertising content. The code attempts to collect the value of the Meta Click ID and upload it along with the page view event.

// Initilize the TD JS SDK  
var td = new Treasure({...});  
  
// Declare to collect Meta Click ID  
td.collectTags(  
  {  
    vendors: ['meta']  
  }  
);  
    
// The tag value will be sent together with the page view event  
td.trackPageview('page_views');  

Behind the scenes, collectTags tries to collect the fbclid request parameter, as well as the _fbc and _fbp cookies, and store them in the $global object which will be sent as part of any tracking payload. Other supported tags from common platforms can be found in Supported Vendor Tags.

The exact names of the cookies or request parameters can be used if you are aware of them

var td = new Treasure({...});  
  
//Declare to collect cookies and url params using their names  
td.collectTags(  
  {  
    cookies: ['_cookie_a', '_cookie_b'],  
    params: ['param_a', 'param_b']  
  }  
);  
    
td.trackPageview('page_views');  

Supported Vendor Names

PlatformVendor name
Google Adsgoogle_ads
Google Analyticsgoogle_ga
Google Marketing Platformgoogle_mp
Metameta
Instagraminstagram
Yahoo! Adsyahoojp_ads
Lineline
X (Twitter)x
Pinterestpinterest
Snapchatsnapchat
Tiktoktiktok
Marketomarketo
Tealiumtealium​