热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用谷歌分析与混合移动应用程序-Usinggoogleanalyticswithhybridmobileapp

WeareintheprocessofturningournativeiPadappintoahybridapp.SomefunctionalityandUIwi

We are in the process of turning our native iPad app into a hybrid app. Some functionality and UI will remain in native code and other functionality will be implemented in HTML that will be served from our servers and will also be available offline.

我们正在将原生iPad应用程序转变为混合应用程序。一些功能和UI将保留在本机代码中,其他功能将以HTML格式实现,这些功能将从我们的服务器提供,也可以脱机使用。

The main issue I encounter now is with using Google Analytics:
The existing native code uses the GA SDK for IOS and I planned on using the web API for the web part, however I can't find how the data from both channels can be used together in GA as the data stores seem to be distinct.

我现在遇到的主要问题是使用Google Analytics:现有的本机代码使用适用于IOS的GA SDK,我计划将Web API用于Web部件,但我无法找到如何使用来自两个渠道的数据在GA中,数据存储似乎是截然不同的。

Furthermore, I plan to use Google Analytics' Content Experiments for A/B testing the web part but conversion goals might be ones achieved in the native part.

此外,我计划使用Google Analytics的内容实验进行A / B测试Web部件,但转换目标可能是在本机部分实现的目标。

Anyone have any experience with analytics on hybrid apps or alternative solutions.

任何人都有混合应用程序或替代解决方案的分析经验。

Thanks

谢谢

3 个解决方案

#1


18  

You really want to use the SDK. It has some features that will come handy for mobile apps like crashes, play store integration. It also sends data in batches to improve battery usage and also can queue hits while the app is offline to be sent when online. You won't be able to emulate that with the Javascript implementations.

你真的想使用SDK。它具有一些功能,可以用于移动应用程序,如崩溃,游戏商店集成。它还可以批量发送数据以提高电池使用率,还可以在应用程序离线时将命中排队,以便在线时发送。您将无法使用Javascript实现来模拟它。

So what you need to write is Javascript methods that send data from the WebView back to the Native Part of the App. This other Stack Overflow thread has more detail on how to do that.

所以你需要编写的是Javascript方法,它们将数据从WebView发送回应用程序的Native部分。这个其他Stack Overflow线程有关于如何执行此操作的更多详细信息。

So the Javascript to track Google Analytics interactions could look something like this.

因此,跟踪Google Analytics互动的Javascript可能看起来像这样。

var _gaq = {};
_gaq.push = function(arr){
  var i, hit;
  hit = arr.slice(1).join('&');
  location.href = 'analytics://'+arr[0]+'?'+arr;
};

Now this will work as a replacement for your ga.js file, you can still use the same API as you use on _gaq today on your Web App, and the adapter above will sends its data to te native part of the APP. And then you just need to write the native part that will intercept that HTTP request and use the native SDK to issue the Google Analytics functions.

现在,这将作为ga.js文件的替代品,您仍然可以使用与Web应用程序上今天_gaq上使用的相同的API,上面的适配器将其数据发送到APP的本机部分。然后,您只需编写将拦截该HTTP请求的本机部分,并使用本机SDK发布Google Analytics功能。

A normal _gaq.push(['_trackPageview', '/homepage']); will become a uri like analytics://_trackPageview?/homepage, now you just need to intercept and parse that on the Native part.

正常的_gaq.push(['_ trackPageview','/ homepage']);将成为uri like analytics:// _ trackPageview?/ homepage,现在你只需要拦截并解析Native部分。

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
    NSURL *url = [request URL];

    NSLog(@"Hit detected %@", url.absoluteString);

    if ([[url scheme] isEqualToString:@"analytics"]) {
        id tracker = [[GAI sharedInstance] defaultTracker];

        if ([url.host isEqualToString:@"_trackPageview"]) {
            // Get the page from parameters and then track the native View.
            // (...)
            [tracker trackView:page];
        }
        else if ([url.host isEqualToString:@"_trackEvent"]) {
            // Get the event parameters from url parameters and then track the native GA Event.
            // (...)
            [tracker trackEventWithCategory:cat
                                 withAction:act
                                  withLabel:lab
                                  withValue:val];
        }
        // Check for all other analytics functions types
        // (...)
        // Cancel the request
        return NO;
    }
    // Not an analytics: request.
    return YES;
}

I hope it have given you a good starting point. Good luck.

我希望它给了你一个很好的起点。祝你好运。

#2


1  

Indeed a challenging configuration.

确实是一个具有挑战性

Have you looked into using analytics.js (Universal Analytics) for the web part ? Then you may be able to feed data into a single App profile

您是否考虑过将analytics.js(Universal Analytics)用于Web部件?然后,您可以将数据提供到单个App配置文件中

Else, you could send all the tracking calls from your backend, by using a server side implementation of the Measurement Protocol but you'll probably loose usage of Content Experiment !

否则,您可以通过使用测量协议的服务器端实现从您的后端发送所有跟踪调用,但您可能会放弃使用内容实验!

#3


0  

I use http://www.flurry.com/ for my apps and Google Analytics for my other stuff. I never mixed both of them in the same app but I'm guessing it's doable. I'd sugest to check out flurry first. There's a good chance it will suffice also for an hybrid app.

我使用http://www.flurry.com/获取我的应用程序,使用Google Analytics获取其他内容。我从来没有在同一个应用程序中混合使用它们,但我猜它是可行的。我想先看看乱舞。混合应用程序也很有可能就足够了。


推荐阅读
  • ! Configuration File for keepalivedglobal_defs {   notification_email {     ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 深入理解Kafka服务端请求队列中请求的处理
    本文深入分析了Kafka服务端请求队列中请求的处理过程,详细介绍了请求的封装和放入请求队列的过程,以及处理请求的线程池的创建和容量设置。通过场景分析、图示说明和源码分析,帮助读者更好地理解Kafka服务端的工作原理。 ... [详细]
  • 本文讨论了在VMWARE5.1的虚拟服务器Windows Server 2008R2上安装oracle 10g客户端时出现的问题,并提供了解决方法。错误日志显示了异常访问违例,通过分析日志中的问题帧,找到了解决问题的线索。文章详细介绍了解决方法,帮助读者顺利安装oracle 10g客户端。 ... [详细]
  • 本文详细介绍了Android中的坐标系以及与View相关的方法。首先介绍了Android坐标系和视图坐标系的概念,并通过图示进行了解释。接着提到了View的大小可以超过手机屏幕,并且只有在手机屏幕内才能看到。最后,作者表示将在后续文章中继续探讨与View相关的内容。 ... [详细]
  • 微软评估和规划(MAP)的工具包介绍及应用实验手册
    本文介绍了微软评估和规划(MAP)的工具包,该工具包是一个无代理工具,旨在简化和精简通过网络范围内的自动发现和评估IT基础设施在多个方案规划进程。工具包支持库存和使用用于SQL Server和Windows Server迁移评估,以及评估服务器的信息最广泛使用微软的技术。此外,工具包还提供了服务器虚拟化方案,以帮助识别未被充分利用的资源和硬件需要成功巩固服务器使用微软的Hyper - V技术规格。 ... [详细]
  • Question该提问来源于开源项目:react-native-device-info/react-native-device-info ... [详细]
  • mysqldinitializeconsole失败_mysql03误删除了所有用户解决办法
    误删除了所有用户解决办法第一种方法(企业常用)1.将数据库down掉[rootdb03mysql]#etcinit.dmysqldstopShuttingdownMySQL..SU ... [详细]
  • 概述H.323是由ITU制定的通信控制协议,用于在分组交换网中提供多媒体业务。呼叫控制是其中的重要组成部分,它可用来建立点到点的媒体会话和多点间媒体会议 ... [详细]
  • 近来有一个需求,是需要在androidjava基础库中插入一些log信息,完成这个工作需要的前置条件有编译好的android源码具体android源码如何编译,这 ... [详细]
  • 【CTF 攻略】第三届 SSCTF 全国网络安全大赛—线上赛 Writeup
    【CTF 攻略】第三届 SSCTF 全国网络安全大赛—线上赛 Writeup ... [详细]
  • Apple iPad:过渡设备还是平板电脑?
    I’vebeenagonizingoverwhethertopostaniPadarticle.Applecertainlydon’tneedmorepublicityandthe ... [详细]
  • Abp+MongoDb改造默认的审计日志存储位置
    一、背景在实际项目的开发当中,使用AbpZero自带的审计日志功能写入效率比较低。其次审计日志数据量中后期十分庞大,不适合与业务数据存放在一起。所以我们可以重新实现A ... [详细]
  • http:www.importnew.com6510.html优先级队列(PriprityQueue)是一种无界队列,基于优先级堆,它的元素根据自然顺序或者通过实现Compar ... [详细]
author-avatar
海豚青春_407
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有