Template: GA4 to Meta Parameters Mapper

GTM variable template that automatically maps GA4 ecommerce parameters to Meta Pixel format. Transforms items array into content_ids and contents, maps value/currency, and adds content_type and order_id for accurate conversion tracking.

E-commerce Parameter Mapping from GA4 to Meta

Introduction: Syncing Your E-commerce Data Between GA4 and Meta

If you run advertising campaigns on Meta (Facebook and Instagram) and track e-commerce data with Google Analytics 4 (GA4), you’ve surely noticed a fundamental discrepancy: the two systems use different parameters and data structures to measure the same events.

This asymmetry can compromise the effectiveness of your dynamic retargeting campaigns, conversion measurement, and value optimization. This Google Tag Manager template was created precisely to solve this problem, providing an automated and reliable solution for mapping e-commerce data from GA4 to the format required by Meta Pixel.


How the Template Works

The template is a custom JavaScript variable designed to be reusable across all your Meta Pixel tags. Its main function is to intercept e-commerce data sent by GA4 (via the Data Layer) and convert it into an object that Meta can understand.

Specifically, the template performs the following operations:

  • Transforms GA4’s items array: Converts the ecommerce.items array, which in GA4 contains all product details, into two key parameters for Meta:
    • content_ids: a simple array containing only product IDs.
    • contents: an array of objects with each product’s details (id, quantity, item_price).
  • Maps main parameters: Automatically extracts and maps parameters like value (order value) and currency directly from GA4’s ecommerce object.
  • Adds specific parameters: Adds additional parameters such as content_type (product or product_group) and order_id (if available), which are essential for accurate tracking and server-side event deduplication via the Conversion API.

Benefits and Advantages

Using this template to map your data offers numerous benefits:

  • Tracking precision: Ensures your e-commerce events are sent to Meta with the correct parameters, improving measurement accuracy.
  • Campaign optimization: Accurate data means more effective optimization for return on ad spend (ROAS) and value-based bidding.
  • Simplified maintenance: The mapping logic resides in a single place (the variable), making tracking maintenance and updates much simpler.
  • Rapid development: Frees you from writing custom code for each event, allowing you to quickly configure tags for Purchase, AddToCart, ViewContent, and other e-commerce events.

How to Install and Configure the Template in GTM

  1. Import the template: In your GTM container, go to Templates > Tag Templates > New. Click the three dots and select Import. Choose the .tpl file of the template you downloaded from the GitHub repository.
  2. Create a new variable: Go to Variables > User-Defined Variables > New. Choose Custom JavaScript as the type and select the template you just imported. Name it, for example, GA4 to Meta Object.
  3. Configure your Meta tags: Create a new Meta Pixel tag.
    • Select the event you want to track (e.g., Purchase).
    • In “Object Properties”, select the “Use Object Parameter” option and enter the name of the variable you just created: {{GA4 to Meta Object}}.
    • Configure the trigger to fire the tag when the corresponding GA4 event occurs (e.g., the purchase event from the Data Layer).
  4. Test and publish: Use GTM’s debug mode to verify that data is being sent correctly to the Meta Pixel, then publish the container.

This way, your e-commerce and Meta advertising campaigns will work in perfect harmony.