Add-on Fire dataLayer upon successful registration and/or payment

sdchan

Member
I am implementing paid marketing campaigns and need some transactional data to be sent to my Google Tag Manager in the following format:


Code:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
    event: "purchase",
    ecommerce: {
        transaction_id: "T_12345", // Replace "T_12345" with Transaction ID
        value: 25.42, // Replace it with the value of order in float
        tax: 4.90, // Replace it with the tax amount of order, leave it null in case of no tax which is in nearly all cases
        currency: "USD", // Replace it with the currency code of the order
        coupon: "SUMMER_SALE", // Replace "SUMMER_SALE" with the coupon code used in order, leave it null in case of no coupon code used
        items: [
            {
                item_id: "SKU_12346", // Replace with the Subscription ID
                item_name: "Google Grey Women's Tee", // Replace with Subscription Name
                price: 20.99, // Replace with FULL price of the subscription
                quantity: 1 // Leave it to 1
            }
        ]
    }
});

Most of this data gets sent to / from the payment providers (Stripe and PayPal). I believe the coupon code used will need to be tracked by the add-on since I can't find it in the payment provider log or Stripe data.

Here is the code that *counts coupon code uses - but maybe this is helpful for tracking the coupon code used for a particular registration:

SQL:
SELECT coupon_code, COUNT(*) total_uses
FROM xf_af_paidregistrations_coupon_use coupon_use
INNER JOIN xf_af_paidregistrations_coupon coupon ON (coupon.coupon_id = coupon_use.coupon_id)
GROUP BY coupon_use.coupon_id
ORDER BY total_uses DESC
 
Top Bottom