OGeek|极客世界-中国程序员成长平台

标题: iOS Google Tag Manager Purchase 事件为数量参数发送 0(零) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:15
标题: iOS Google Tag Manager Purchase 事件为数量参数发送 0(零)

注意:已在帖子中提出:Quantities of items are not tracked in google analytics transactions但没有回答。

当使用适用于 iOS (Objective-C) 的 Google 跟踪代码管理器([编辑] 版本 3.06)并发送购买事件时,如 the example 中所述事件被发送,我可以在 Google Analytics 后端读回它,但是数量的值始终为 0(零)。价格也是 0(零),但我不确定这是否是由于数量为 0 造成的。其他所有参数似乎都可以正常发送。

请注意,我实现了 android SDK 没有问题。

现在的代码是(为了可读性而改变的):

int quantity = 1;
float price = 0.89f;
float shipping = 0.0f;
float tax = 0.0f;

TAGDataLayer *dataLayer = [TAGManager instance].dataLayer;

NSMutableArray *purchasedItems = [NSMutableArray array];

[purchasedItems addObject{@"name": GetStringParam(name),
                            @"sku": GetStringParam(SKU),
                            @"category": GetStringParam(category),
                            @"price": [NSNumber numberWithFloat:price],
                            @"currency": @"EUR",
                            @"quantity": [NSNumber numberWithInt:quantity]
                            }];

[dataLayer push{@"event": @"Transaction",
                  @"transactionId": GetStringParam(transactionID),
                  @"transactionTotal": [NSNumber numberWithInt:quantity],
                  @"transactionAffiliation": GetStringParam(affiliation),
                  @"transactionTax": [NSNumber numberWithFloat:tax],
                  @"transactionShipping": [NSNumber numberWithFloat:shipping],
                  @"transactionCurrency": @"EUR",
                  @"transactionProducts": purchasedItems
                  }];

[dataLayer push{@"transactionId": [NSNull null],
                  @"transactionTotal": [NSNull null],
                  @"transactionAffiliation": [NSNull null],
                  @"transactionTax": [NSNull null],
                  @"transactionShipping": [NSNull null],
                  @"transactionCurrency": [NSNull null],
                  @"transactionProducts": [NSNull null]
                  }];

我做错了什么还是 GTM SDK for iOS 的已知问题?我真的很想在这方面得到一些帮助。

更新:只是想添加 GTM 生成的日志:

Saved hit: {
parameters =     {
    "&_u" = ".L";
    "&_v" = "mi3.0.6";
    "&aid" = "[this is confidential]";
    "&an" = "[this is confidential]";
    "&av" = "[this is confidential]";
    "&cd" = "/Home";
    "&cid" = "60dc5171-1a8d-40ed-9f90-cc2cb1bbb30d";
    "&cu" = EUR;
    "&ic" = "Test-SKU";
    "&in" = "Test-name";
    "&ip" = "0.89";
    "&iq" = 1;
    "&iv" = "Test-category";
    "&sr" = 320x480;
    "&t" = item;
    "&ti" = "TEST-PURCHASE_JXJKY0N8";
    "&tid" = "UA-XXXXXX-2";
    "&ul" = en;
    "&v" = 1;
    "&z" = 12665685598291294076;
    gaiVersion = "3.06";
};
timestamp = "2014-04-10 11:02:23 +0000";
}

如果需要任何其他信息,请告诉我。

干杯, 尼尔斯



Best Answer-推荐答案


iOS SDK 的当前(3.06 版本)存在一个错误,因此您不应在推送的电子商务事件中提供 NSNumbers 作为值。解决方法是改用字符串(例如,[NSString stringWithFormat @"%1.2f", price])。

我们正在努力修复这个错误。

Neil(移动应用技术主管的 Google 跟踪代码管理器)

关于iOS Google Tag Manager Purchase 事件为数量参数发送 0(零),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22985976/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4