Transforming Data Layer Events

For special circumstances, you can provide your own function that will be called for all data layer events. This provides a hook for modifying a data layer event before it is pushed into the data layer. This use case isn’t primarily applicable to non-shopify sites since the developers implement their own custom data layer, but it can be used to customize the enriched data for each data layer event

window.ElevarTransformFn = item => {
	if (item.event === "dl_add_to_cart") {
		return {...item, custom_property: "my_custom_property"};
	} else {
		return item;

When any data layer event is pushed, this custom_property will be used.

// logs my_custom_property

What’s Next