How to track extra parameters?

As you integrate more tools you may want to extend the standard GA4 eCommerce Events structure with custom parameters.

You can quickly do that by simple PHP snippet that use `setExtraProperty` method on the ecommerce event item (that represents your product).

In this example we will pass extra parameter related to product rating:

add_filter("gtm_ecommerce_woo_item", function($item, $product) {
	$item->setExtraProperty("rating", $product->get_average_rating());
	return $item;
}, 10, 2);<br>

That way you can later access it in your custom GTM JS tags in following way:

<script>
  var items = {{GA4 Ecommerce Items}};
  items.map(function(item) {
	console.log(item.rating);
  });
</script>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.