jjzjj

iOS Google Tag Manager Purchase 事件为数量参数发送 0(零)

coder 2024-01-19 原文

注:已在帖子中提出: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";
}

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

干杯, 尼尔斯

最佳答案

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

我们正在努力修复错误。

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

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

有关iOS Google Tag Manager Purchase 事件为数量参数发送 0(零)的更多相关文章

  1. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  2. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  3. ruby - RSpec - 使用测试替身作为 block 参数 - 2

    我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere

  4. ruby - 如何在 Ruby 中拆分参数字符串 Bash 样式? - 2

    我正在为一个项目制作一个简单的shell,我希望像在Bash中一样解析参数字符串。foobar"helloworld"fooz应该变成:["foo","bar","helloworld","fooz"]等等。到目前为止,我一直在使用CSV::parse_line,将列分隔符设置为""和.compact输出。问题是我现在必须选择是要支持单引号还是双引号。CSV不支持超过一个分隔符。Python有一个名为shlex的模块:>>>shlex.split("Test'helloworld'foo")['Test','helloworld','foo']>>>shlex.split('Test"

  5. ruby - 检查方法参数的类型 - 2

    我不确定传递给方法的对象的类型是否正确。我可能会将一个字符串传递给一个只能处理整数的函数。某种运行时保证怎么样?我看不到比以下更好的选择:defsomeFixNumMangler(input)raise"wrongtype:integerrequired"unlessinput.class==FixNumother_stuffend有更好的选择吗? 最佳答案 使用Kernel#Integer在使用之前转换输入的方法。当无法以任何合理的方式将输入转换为整数时,它将引发ArgumentError。defmy_method(number)

  6. ruby-on-rails - 在默认方法参数中使用 .reverse_merge 或 .merge - 2

    两者都可以defsetup(options={})options.reverse_merge:size=>25,:velocity=>10end和defsetup(options={}){:size=>25,:velocity=>10}.merge(options)end在方法的参数中分配默认值。问题是:哪个更好?您更愿意使用哪一个?在性能、代码可读性或其他方面有什么不同吗?编辑:我无意中添加了bang(!)...并不是要询问nobang方法与bang方法之间的区别 最佳答案 我倾向于使用reverse_merge方法:option

  7. ruby - 定义方法参数的条件 - 2

    我有一个只接受一个参数的方法:defmy_method(number)end如果使用number调用方法,我该如何引发错误??通常,我如何定义方法参数的条件?比如我想在调用的时候报错:my_method(1) 最佳答案 您可以添加guard在函数的开头,如果参数无效则引发异常。例如:defmy_method(number)failArgumentError,"Inputshouldbegreaterthanorequalto2"ifnumbereputse.messageend#=>Inputshouldbegreaterthano

  8. jquery - 我的 jquery AJAX POST 请求无需发送 Authenticity Token (Rails) - 2

    rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送

  9. ruby - rails 3 redirect_to 将参数传递给命名路由 - 2

    我没有找到太多关于如何执行此操作的信息,尽管有很多关于如何使用像这样的redirect_to将参数传递给重定向的建议:action=>'something',:controller=>'something'在我的应用程序中,我在路由文件中有以下内容match'profile'=>'User#show'我的表演Action是这样的defshow@user=User.find(params[:user])@title=@user.first_nameend重定向发生在同一个用户Controller中,就像这样defregister@title="Registration"@user=Use

  10. ruby - 字符串文字中的转义状态作为 `String#tr` 的参数 - 2

    对于作为String#tr参数的单引号字符串文字中反斜杠的转义状态,我觉得有些神秘。你能解释一下下面三个例子之间的对比吗?我特别不明白第二个。为了避免复杂化,我在这里使用了'd',在双引号中转义时不会改变含义("\d"="d")。'\\'.tr('\\','x')#=>"x"'\\'.tr('\\d','x')#=>"\\"'\\'.tr('\\\d','x')#=>"x" 最佳答案 在tr中转义tr的第一个参数非常类似于正则表达式中的括号字符分组。您可以在表达式的开头使用^来否定匹配(替换任何不匹配的内容)并使用例如a-f来匹配一

随机推荐