简体   繁体   English

ionic应用程序中的Google Analytics(分析)自定义维度

[英]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.

相关问题 Google Analytics(分析)自定义维度 - Google analytics custom dimensions 如何在Google Analytics(分析)中取得具有自订维度的clientId - How to get clientId with custom dimensions in google analytics 随时修改Google Analytics自定义维度 - Modify Google Analytics custom dimensions on the go 如何在Google Analytics(分析)中设置自定义维度 - How to set custom dimensions in Google Analytics Google Analytics 不发送带有网页浏览点击的自定义维度 - Google analytics not sending custom dimensions with pageview hits Google Analytics(分析)使用gtag发送两个自定义维度 - Google Analytics send two custom dimensions with gtag 在Google AnalyticsAPI中使用和查询自定义维度 - Using and querying Custom Dimensions in Google Analytics API 我的自定义维度和指标没有显示在Google Analytics(分析)中? - My Custom Dimensions & Metrics don't show in Google Analytics? 通过Google跟踪代码管理器在Universal Analytics中实现多值自定义维度 - Multivalue Custom Dimensions in Universal Analytics through Google Tag Manager 如何注册一个独特的页面视图以及如何使用自定义维度Google Analytics - How to register a uniquePageview and how to use custom dimensions google analytics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM