
February 28, 2023
How to reuse GA4 ecommerce data in Tiktok Pixel
This will be a short blog post (because all the necessary things are covered in the video below). But I hope to find more time in the future and turn this into a wholesome article.
This blog post presumes that you have already installed Tiktok Pixel with Google Tag Manager. If you haven’t done that, watch this tutorial first.
Video: Reuse GA4 e-commerce data in Tiktok Pixel
In the video below, I am using Google Tag Manager to do that.
At one point in the video, I will mention a JavaScript code that you need to use in a Custom JavaScript variable. Here it is:
function(){ var ec = INSERT_YOUR_ECOMMERCE_VARIABLE_HERE; var ecItems = ec.items return ecItems.map(function(product){ return { "content_id" : !!product.item_id ? product.item_id.toString() : undefined, "price" : !!product.price ? parseFloat(product.price) : undefined, "quantity" : !!product.quantity ? parseInt(product.quantity) : undefined, "content_name" : !!product.item_name ? product.item_name.toString() : undefined } }) }
Make sure you create a Data Layer variable accessing the ecommerce object (version 1). Then replace the INSERT_YOUR_ECOMMERCE_VARIABLE_HERE part with that variable.
This variable will take all products that are available in the data layer (ecommerce.items) and then outputs the format supported by the Tiktok Pixel.
Final words
Also, don’t forget to use Tag Sequencing and make sure that your Pixel base tag (implemented with a Custom HTML tag) fires before the event tag.
But the base code does not “like” when it fires multiple times, these your Custom HTML tag should be set to fire only once per page.

0 COMMENTS