[英]Google Analytics custom dimensions within ionic app
I created a new custom dimension by the name of 'username' in my analytics and got the following snippet from google analytics. 我在分析中以“用户名”的名称创建了一个新的自定义维度,并从Google Analytics(分析)中获取了以下代码段。
var dimensionValue = 'SOME_DIMENSION_VALUE'; ga('set', 'dimension1', dimensionValue);
I have an Ionic app in which I am using the Google analytics plugin : https://github.com/danwilson/google-analytics-plugin/tree/f415646 我有一个使用Google Analytics(分析)插件的Ionic应用: https : //github.com/danwilson/google-analytics-plugin/tree/f415646
The plugin is working for reporting everything like views, etc. Now I want to track the above mentioned custom dimension. 该插件可用于报告视图等所有内容。现在,我想跟踪上述自定义维度。
As per the example, I entered the following in my app: 按照示例,我在应用程序中输入了以下内容:
window.analytics.addCustomDimension('dimension1', uName,
function(){
//success
alert('dimension data saved');
}, function(){
//error
alert('An error occured');
}
);
uName variable contains the correct value. uName变量包含正确的值。 If I add console log it shows correctly.
如果添加控制台日志,它将正确显示。 Also, the success alert is shown on the app.
此外,成功警报也会显示在应用程序上。 But it is not working.
但这是行不通的。 This does not show any reports on my dashboard when I filter by the specified dimension.
当我按指定的维度进行过滤时,这不会在我的仪表板上显示任何报告。
However, the following works fine (both these lines are together, one after another): 但是,以下方法可以很好地工作(这两行在一起,一个接一个):
window.analytics.trackView(currentState.name);
Has anyone successfully tracked custom dimensions for an app built with ionic / cordova ? 有没有人成功跟踪过使用ionic / cordova构建的应用的自定义尺寸? don't know what is that I am doing wrong here.
不知道我在这里做错了什么。
After going through the plugin source code I found that the 'key' parameter needs to be an integer and not a string. 在查看了插件源代码之后,我发现'key'参数需要是整数而不是字符串。
Modifying the code as mentioned below solved the issue: 如下所述修改代码即可解决此问题:
window.analytics.addCustomDimension(1, customValue, success, failure);
Hope this helps someone... 希望这可以帮助某人...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.