Google跟踪代码管理器标准电子商务

时间:2019-05-08 16:50:01

标签: javascript google-analytics e-commerce google-tag-manager google-datalayer

我正在尝试在Google跟踪代码管理器中设置标准电子商务。

但是,Google Analytics(分析)没有收到我的交易数据;我正在尝试通过Google跟踪代码管理器的dataLayer将数据推送到Google Analytics(分析)-但是,当我重新加载收据页面时,Google Analytics(分析)仪表板中没有任何报告。

这是我写的代码:(此代码执行上方GTM标签)

window.dataLayer = window.dataLayer || [];
@*Send the receipt information to Google*@
        dataLayer.push(
            {
                'transactionId': '@Model.StudentCheckoutReceiptId',
                'transactionAffiliation': 'AcmeStudios',
                'transactionRevenue': @Model.Total,
                'transactionShipping': '@Model.ShippingOptionPurchased.ToString()',
                'transactionProducts': {
                    'id': '@Model.StudentCheckoutReceiptId',
                    'name': '@packageOption',
                    'price': @Model.Total,
                    'quantity': 1
                }
            });
// GTM include
....
// End GTM include

页面加载后,dataLayer如下所示: enter image description here

但是,Google Analytics(分析)没有收到任何信息: enter image description here

这是我的Google跟踪代码管理器配置: enter image description here enter image description here enter image description here

我的收据页面的网址:

https://acmestudios.com/receipt/1aa2726f-9881-43b4-ba42-34a5510d8e67

我想念什么?

1 个答案:

答案 0 :(得分:0)

我正确地设置了所有内容,但dataLayer对象不正确;如果您不遵循Google指定的格式和变量名完全,那么它将无法正常工作;您还需要确保传入任何Required参数。这是我的dataLayer现在的样子:

@*Send the receipt information to Google*@
dataLayer.push(
    {
        'transactionId': '@Model.ReceiptId',
        'transactionAffiliation': 'AcmeProducts',
        'transactionTotal': @Model.Total,
        'transactionShipping': '@Model.ShippingOptionPurchased.ToString()',
        'transactionProducts': [{
            'name': '@packageOption',
            'sku': 'none',
            'price': @Model.Total,
            'quantity': 1
        }]
    });