The purchase event on shopify purchases is showing revenue values that are close but do not match the purchase value. The event value appears correct, but ecommerce revenue seems to be changing the value a small amount.
Any ideas on a fix?
The 60 event value is what it should be.
Data Layer purchase event:
/** DATALAYER: Checkout on Shopify Plus **/
if(Shopify.Checkout){
var ecommerce = {
'transaction_id': '{{checkout.order_number | json}}',
'affiliation': {{shop.name | json}},
'value': {{checkout.total_price | money_without_currency | replace: ',', '.' | json}},
'tax': {{checkout.tax_price | money_without_currency | replace: ',','.' | json}},
'shipping': {{checkout.shipping_price | money_without_currency | replace: ',','.' | json}},
'subtotal': {{checkout.subtotal_price | money_without_currency| replace: ',','.' | json}},
'currency': {{checkout.currency | json}},
{% for discount in checkout.discounts %}
'coupon': {{discount.code | json}},
'discount' : {{discount.amount | money_without_currency | json}},
{% endfor %}
'email': {{checkout.email | json}},
'items':[{% for line_item in checkout.line_items %}{
'item_id' : '{{line_item.product.id | json}}',
'item_variant' : {{line_item.variant.title | json}},
'item_name' : {{line_item.product.title | json}},
'price' : {{line_item.product.price | money_without_currency | replace: ',', '.' | json}},
'item_brand' : {{line_item.product.vendor | json}},
'item_category' : {{line_item.product.type | json}},
'item_list_name' : {{line_item.collection.title | json}},
'quantity' : {{line_item.quantity | json}},
'discount' : {{discount.code | json}}
},{% endfor %}],
};
if(Shopify.Checkout.step){
if(Shopify.Checkout.step.length > 0){
if (Shopify.Checkout.step === 'contact_information'){
dataLayer.push({
'event' :'begin_checkout',
'pageType' :'Customer Information',
'step': 1,
ecommerce
});
}else if (Shopify.Checkout.step === 'shipping_method'){
dataLayer.push({
'event' :'add_shipping_info',
'pageType' :'Shipping Information',
ecommerce
});
}else if( Shopify.Checkout.step === "payment_method" ){
dataLayer.push({
'event' :'add_payment_info',
'pageType' :'Add Payment Info',
ecommerce
});
}
}
/** DATALAYER: Transaction */
if(Shopify.Checkout.page == "thank_you"){
dataLayer.push({
'pageType' :'Transaction',
'event' :'purchase',
ecommerce
});
}
}
}
I've tested in tag assistant and the values on the order are as expected in the data layer. But using the ecommerce metrics in GA4, something is changing the values slightly. Currency matches in GA4, dataLayer & shopify.
Thinking it could be something to do with this:
{{checkout.total_price | money_without_currency | replace: ',', '.' | json}}
Any help or resources appreciated!