Skip to main content

Documentation Portal

Global‑e and Marketing Pixels

With the Global-e solution installed, your store has now two types of checkouts, the standard checkout for your local customers and the Global-e checkout for your international customers.

marketing_pixels2.png

This document provides you, the merchant, with the basic instructions required to implement tracking events on your website.

MEASURING PLATFORM EVENTS

To measure marketing platform events on the Global-e checkout, you must add the pixels or tags of the relevant marketing platforms to the pages containing Global-e checkout, as described in this document

RELATED DOCUMENTATION

For detailed technical documentation, see Global-e Order Transaction Support for Analytics

Adding Pixels to the Global-e Checkout

Global‑e provides a JavaScript callback function (“OnCheckoutStepLoaded”) that holds the checkout and order information in a data object. You can use this callback to trigger events both when the Global‑e checkout is loaded or complete.

To embed pixels in the Global-e checkout:

  1. Edit the OnCheckoutStepLoaded callback function by adding the relevant pixels snippets to the callback function.1. Edit the OnCheckoutStepLoaded Callback Function

  2. Place the final OnCheckoutStepLoaded callback function on your site.2. Place the Final OnCheckoutStepLoad Callback on your Site

  1. Edit the OnCheckoutStepLoaded Callback Function

    The following code snippet presents the subscription to the OnCheckoutStepLoaded callback function. Note that this code currently does not contain any pixels.

    data.Steps.LOADEDloaded, while the data.Steps.CONFIRMATION case is executed when the Global‑e checkout has been completed.

     <script>
    
    var glegem = glegem || function() {
    ((window["glegem"] = window["glegem"] || {q:[]}).q = window["glegem"].q || []).push(arguments);};var glegem = window["glegem"] || function () {
        (window["glegem"].q = window["glegem"].q || []).push(arguments);
    };
    glegem("OnCheckoutStepLoaded", function (data) {
        switch (data.StepId) {
        case data.Steps.LOADED:
         // ******************************************* // 
         // ** ADD CHECKOUT LOADED EVENT PIXELS HERE ** //
         // ******************************************* //
            break;
        case data.Steps.CONFIRMATION:
            if (data.IsSuccess) {
               // *********************************************************** //
               // ** ADD CHECKOUT COMPLETED/CONFIRMATION EVENT PIXELS HERE ** //
               // *********************************************************** //
            }
            break;
        }
    });
    </script >

    We recommend deferring the Global-e scripts until after the entire document has been parsed. Hopefully, this will allow any analytics code to load onto the page before the Global-e analytics scripts load.

    If the above recommendations do not improve the situation, we recommend you add your analytics code to the source of the checkout page, assuming there are no reasons preventing that from happening.

    Converted price analytics

    You may need to capture converted prices in analytics that run on your product page and other pages before checkout. To do this, there is an event that triggers after the prices on the page are converted. You can subscribe to this event, and after it triggers, you can execute your analytics, so you are able to retrieve the converted prices.

    window['GlobalE_Prices_Conversion_Complete'] = function() { console.log('GE prices conversion complete')};

    As mentioned, the callback returns a data object in JSON format that contains information about the checkout, such as item prices and quantities, order total, and currency. Use the variables in the JSON data object to configure your pixel.

    See Data Object Confirmation Step (JSON) for an example.

    Use the relevant data object variables to add pixels to the LOADED step, the CONFIRMATION step, or both.

    The following examples show how this is edited or amended for each marketing platform.

    Platform

    Event

    Example

    Google Tag Manager (Data Layer)

    Purchase Event

    Google Tag Manager (Purchase Data Layer)

    Google Ads (gtag)

    Conversion Event

    gtag - Conversion Event

    TikTok

    PlaceAnOrder Event

    TikTok - PlaceAnOrDer Event

  2. Place the Final OnCheckoutStepLoad Callback on your Site

    To implement the final OnCheckoutStepLoad callback on your site:

    OnCheckoutStepLoadedonline store, in the head element.

    Note that the callback function is only initiated when the Global‑e checkout is loaded or complete, even though the function is implemented on every page of your site.

Common Data Object Variables

The following table lists the most common data object variables used in marketing platforms events:

Variable Definition

Variable JSON Path

Global-e Order Id

data.details.OrderID

The merchant currency: The Store currency

data.details.MerchantCurrencyCode

Order products total (in merchant currency)

data.details.OrderPrices.MerchantTransaction.TotalProductsPrice

Single product sale price (in base Store currency)

data.details.ProductInformation[i].ProductPrices.MerchantTransaction.SalePrice

Single product quantity

data.details.ProductInformation[i].Quantity

Single product SKU

data.details.ProductInformation[i].SKU

See Global-e Order Transaction Support for Analytics for the complete list of variables.

Google Tag Manager (Purchase Data Layer)
<script>
var glegem = glegem || function() {
((window["glegem"] = window["glegem"] || {q:[]}).q = window["glegem"].q || []).push(arguments);};var glegem = window["glegem"] || function () {
    (window["glegem"].q = window["glegem"].q || []).push(arguments);
};
glegem("OnCheckoutStepLoaded", function (data) {
    switch (data.StepId) {
    case data.Steps.LOADED:
        break;
    case data.Steps.CONFIRMATION:
        console.log(data);
        if (data.IsSuccess) {
            if (typeof dataLayer !== "undefined") {
                let products = new Array();
                for (let temp = 0;
                    temp < data.details.ProductInformation.length; temp++) {
                    let tempProducts = {};
                    tempProducts.id =
                         data.details.ProductInformation[temp].SKU;
                    tempProducts.name =
                        data.details.ProductInformation[temp].ProductName;
                    tempProducts.price = data.details.ProductInformation[temp].
                        ProductPrices.MerchantTransaction.SalePrice;
                    tempProducts.quantity =
                        data.details.ProductInformation[temp].Quantity;
                    products.push(tempProducts);
                }
                var couponCode = '';
                var discountAmount = '';
                for (let temp = 0; temp < data.details.Discounts.length; temp++) {
                    if (data.details.Discounts[temp].CouponCode !=
                        '' && data.details.Discounts[temp].DiscountTypeId == 1) {
                        couponCode =
                            data.details.Discounts[temp].CouponCode;
                        discountAmount =
                            data.details.Discounts[temp].
                            DiscountPrices.MerchantTransaction.Price;
                    }
                }
                dataLayer.push({
                    'event': 'purchase_GE',
                    'ecommerce': {
                        'purchase': {
                            'actionField': {
                                'id': data.OrderId,
                                'revenue':
                                data.details.OrderPrices.
                                MerchantTransaction.TotalProductsPrice,
                                'coupon': couponCode,
                                'discountAmount': discountAmount
                            },
                            'products': products
                        },
                        "currencyCode": data.details.MerchantCurrencyCode,
                    }
                });
            }
        }
        break;
    }
});
</script>
gtag - Conversion Event
<script>
var glegem = glegem || function() {
((window["glegem"] = window["glegem"] || {q:[]}).q = window["glegem"].q || []).push(arguments);};var glegem = window["glegem"] || function () {
    (window["glegem"].q = window["glegem"].q || []).push(arguments);
};
glegem("OnCheckoutStepLoaded", function (data) {
    switch (data.StepId) {
    case data.Steps.LOADED:
        break;
    case data.Steps.CONFIRMATION:
        if (data.IsSuccess) {
            gtag('event', 'conversion', {
                'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
                'value': data.details.OrderPrices.
                MerchantTransaction.TotalProductsPrice,
                'currency': data.details.MerchantCurrencyCode,
                'transaction_id': data.OrderId,
            });
        }
        break;
    }
});
</script>
TikTok - PlaceAnOrDer Event
<script>
var glegem = glegem || function() {
((window["glegem"] = window["glegem"] || {q:[]}).q = window["glegem"].q || []).push(arguments);};var glegem = window["glegem"] || function () {
    (window["glegem"].q = window["glegem"].q || []).push(arguments);
};
glegem("OnCheckoutStepLoaded", function (data) {
    switch (data.StepId) {
    case data.Steps.LOADED:
        break;
    case data.Steps.CONFIRMATION:
        if (data.IsSuccess) {
            let products = new Array();
            for (let temp = 0; temp < 
                data.details.ProductInformation.length; temp++) {
                let tempProducts = {};
                tempProducts.Content_id = 
                    data.details.ProductInformation[temp].SKU;
                tempProducts.Content_name = 
                     data.details.ProductInformation[temp].ProductName;
                tempProducts.Price =
                    data.details.ProductInformation[temp].
                    ProductPrices.MerchantTransaction.SalePrice;
                tempProducts.Quantity =
                     data.details.ProductInformation[temp].Quantity;
                tempProducts.Currency = data.details.MerchantCurrencyCode;
                products.push(tempProducts);
            }
            ttq.track('PlaceAnOrder', {
                'contents': products,
                'value':
                     data.details.OrderPrices.MerchantTransaction.TotalProductsPrice,
                'currency': data.details.MerchantCurrencyCode
            });
        }
        break;
    }
});
</script> 
Data Object Confirmation Step (JSON)

The following example illustrates the data object confirmation step in JSON format.

{
    "data": {
        "Steps": {
            "LOADED": 0,
            "CONFIRMATION": 4
        },
        "IsSuccess": true,
        "OrderId": "GE158530011GB",
        "MerchantOrderId": null,
        "AuthCode": 5,
        "StepId": 4,
        "details": {
            "OrderID": "GE158530011GB",
            "MerchantOrderID": null,
            "ReplacementOrder": false,
            "CustomerCurrencyCode": "EUR",
            "MerchantCurrencyCode": "GBP",
            "IsEU": false,
            "CustomerDetails": {
                "ShippingAddress": null,
                "BillingAddress": null
            },
            "HubCountryCode": "GB",
            "Region": null,
            "SiteURL": "https://andrii-sh12.myshopify.com",
            "DutiesGuaranteed": true,
            "ShippingMethodName": "DHL",
            "ShippingMethodType": "Express Courier (Air)",
            "DeliveryDaysRangeFrom": 2,
            "DeliveryDaysRangeTo": 2,
            "OrderPrices": {
                "MerchantTransaction": {
                    "EstimatedTotalPrice": 0.43,
                    "TotalProductsPrice": 2.98,
                    "TotalDiscountedProductsPrice": 2.98,
                    "EstimatedShippingCost": 2.55,
                    "ShippingVATRate": 0,
                    "DutiesAndTaxes": 0,
                    "ProductTotalVAT": 0.5,
                    "TotalVAT": 0.5,
                    "RemoteAreaSurchargeFee": 0
                },
                "MerchantTransactionExcludingLocalVAT": {
                    "EstimatedTotalPriceExcludingVAT": -0.07,
                    "TotalProductsPriceExcludingVAT": 2.48,
                    "TotalDiscountedProductsPriceExcludingVAT": 2.48,
                    "EstimatedShippingCostExcludingVAT": 2.55,
                    "CustomerShippingPriceExcludingVAT": 15,
                    "DutiesAndTaxesExcludingVAT": 0,
                    "RemoteAreaSurchargeFeeExcludingVAT": 0
                },
                "CustomerTransaction": {
                    "CustomerTotalPrice": 17.95,
                    "CustomerTotalProductsPrice": 2.95,
                    "CustomerTotalDiscountedProductsPrice": 2.95,
                    "CustomerShippingPrice": 15,
                    "CustomerDutiesAndTaxes": 0,
                    "CustomerTotalVAT": 0,
                    "CustomerShippingVATRate": 0,
                    "CustomerUSSalesTax": 0,
                    "Fees": {
                        "CustomerCCF": 0,
                        "CustomerCODFee": 0,
                        "CustomerDangerousGoodsFee": 0,
                        "CustomerSizeOverchargeFee": 0,
                        "CustomerRemoteAreaSurchargeFee": 0
                    }
                },
                "CustomerTransactionInMerchantCurrency": {
                    "CustomerTotalPriceInMerchantCurrency": 15.56,
                    "CustomerTotalProductsPriceInMerchantCurrency": 2.56,
                    "CustomerTotalDiscountedProductsPriceInMerchantCurrency": 2.56,
                    "CustomerShippingPriceInMerchantCurrency": 13,
                    "CustomerVATInMerchantCurrency": 0,
                    "CustomerShippingVATRate": 0,
                    "CustomerDutiesAndTaxesInMerchantCurrency": 0,
                    "CustomerUSSalesTaxInMerchantCurrency": 0,
                    "Fees": {
                        "CustomerCCFInMerchantCurrency": 0,
                        "CustomerCODFeeInMerchantCurrency": 0,
                        "CustomerDangerousGoodsFeeInMerchantCurrency": 0,
                        "CustomerSizeOverchargeFeeInMerchantCurrency": 0,
                        "CustomerRemoteAreaSurchargeFeeInMerchantCurrency": 0
                    }
                }
            },
            "ProductInformation": [{
                    "ProductName": "Blue T-Shirt test",
                    "ProductURL": 
                        "https://sh15.myshopify.com/products/
                                 blue-t-shirt?variant=38153717350595",
                    "Categories": null,
                    "Brand": null,
                    "SKU": "66466",
                    "ProductGroupCode": "6254011384003",
                    "SecondaryProductCode": null,
                    "Quantity": "1",
                    "CartItemId": "38153717350595:00db6f4e2962eae384bbdac28ed08472",
                    "ProductCouponCodes": null,
                    "ParentCartItemID": null,
                    "CartItemOptionId": null,
                    "MetaData": [{
                            "AttributeKey": "size",
                            "AttributeValue": "L"
                        }, {
                            "AttributeKey": "size",
                            "AttributeValue": "L"
                        }
                    ],
                    "ProductAttributes": null,
                    "ProductPrices": {
                        "MerchantTransaction": {
                            "ListPrice": 2.98,
                            "SalePrice": 2.98,
                            "TotalPrice": 2.98,
                            "VATRate": 20,
                            "DiscountedPrice": 2.98
                        },
                        "MerchantTransactionExcludingLocalVAT": {
                            "ListPriceExcludingVAT": 2.48,
                            "SalePriceExcludingVAT": 2.48,
                            "TotalPriceExcludingVAT": 2.48,
                            "DiscountedPriceExcludingVAT": 2.48
                        },
                        "CustomerTransaction": {
                            "CustomerListPrice": 2.95,
                            "CustomerSalePrice": 2.95,
                            "CustomerTotalPrice": 2.95,
                            "CustomerVATRate": 0,
                            "CustomerDiscountedPrice": 2.95
                        },
                        "CustomerTransactionInMerchantCurrency": {
                            "CustomerListPriceInMerchantCurrency": 2.56,
                            "CustomerSalePriceInMerchantCurrency": 2.56,
                            "CustomerTotalPriceInMerchantCurrency": 2.56,
                            "CustomerDiscountedPriceInMerchantCurrency": 2.56
                        }
                    }
                }
            ],
            "PaymentMethods": [{
                    "PaymentMethodName": "Visa",
                    "PaymentMethodCode": "1"
                }
            ],
            "Discounts": [{
                    "Description":
                       "Shipping discount provided from fixed price range 443543",
                    "DiscountCode": null,
                    "DiscountTypeId": 2,
                    "DiscountTypeName": "Shipping discount",
                    "CouponCode": "",
                    "ProductCartItemId": null,
                    "DiscountPrices": {
                        "MerchantTransaction": {
                            "Price": 2.55,
                            "VATRate": 0
                        },
                        "MerchantTransactionExcludingLocalVAT": {
                            "PriceExcludingVAT": 2.55
                        },
                        "CustomerTransaction": {
                            "CustomerPrice": 3.03,
                            "CustomerVATRate": 0
                        },
                        "CustomerTransactionInMerchantCurrency": {
                            "CustomerPriceInMerchantCurrency": 2.63,
                            "CustomerVATRate": 0
                        }
                    }
                }
            ],
            "OrderPaymentMethods": [{
                    "PaymentMethodId": 1,
                    "PaymentMethodName": "Visa",
                    "IsGiftCard": false,
                    "GiftCardFields": null,
                    "PaidAmountInCustomerCurrency": 17.95,
                    "PaidAmountInMerchantCurrency": 15.115259535867043
                }
            ],
            "cultureCode": "en-GB",
            "InitialCheckoutCultureCode": "en-GB",
            "URL": null,
            "CustomURL": null,
            "CheckoutStep": null,
            "MerchantID": 10000085,
            "Title": "Global‑e Order Transaction",
            "HostName": "https://qa.bglobale.com/",
            "CustomHostName": null,
            "PageType": 0,
            "CartToken": "697ed452-a5a0-4ee2-b3a0-714b7b053158",
            "CountryCode": "DE",
            "UrlReferer": null,
            "DoLog": false
        }

    }
}
Converted price analytics

You may need to capture converted prices in analytics that run on your product page and other pages before checkout. To do this, there is an event that triggers after the prices on the page are converted. You can subscribe to this event, and after it triggers, you can execute your analytics, so you can retrieve the converted prices.

window['GlobalE_Prices_Conversion_Complete'] = function() { console.log('GE prices conversion complete')};