9

Is it possible to use Google Analytics with Android Wear directly?

Meaning, can I create Trackers etc... directly in my wear app, or do I have to send the data to the handset as a proxy to the analytics service?

UPDATE: I have tried using Analytics directly from the Wearable, and so far I'm getting nothing (nothing shows up in the analytics dashboard, and there are no logs pertaining to anything analytics related).

Eliezer
  • 7,209
  • 12
  • 56
  • 103
  • As of today, Android Wear apps cannot access the network directly, so I don't think creating a `Tracker` in the wearable would work. But I haven't actually tested this. – matiash Jul 11 '14 at 20:37
  • 1
    I'm only asking because I'm not sure if a `Tracker` directly accesses the network, or proxies through GPS. – Eliezer Jul 11 '14 at 20:40
  • Actually, you're right. It used to do so when Analytics was a standalone jar that you placed in your project. Now that it's a part of Play Services, I'm not so sure. Good point. – matiash Jul 11 '14 at 20:58
  • 1
    You should be able to. You can get GPS from GPS (lol, location from Google Play Services), so you should be able to do this, too. Joe Lapenna confirmed it here: https://plus.google.com/101359495458898711218/posts/FhkgND7USgx – gatlingxyz Jul 15 '14 at 19:41
  • He doesn't mention Analytics specifically, but I'll update when I get a chance to try that out. – Eliezer Jul 15 '14 at 23:05

2 Answers2

3

Android Wear devices aren't directly connected to the internet so you can't use the Google Analytics API directly. You have to forward the events from the Wear device to your host device (which is connected to the internet), and that will then talk to Google Analytics.

Here's a snippet that shows you how to do that, although for a slightly different use case.

At Segment, we've developed an extension to our Android library that lets you use Analytics for a ton of tools from Android Wear. So instead of having to write your own code to forward all the events, you can just do WearAnalytics.with(context).track(...).

Disclaimer: I work for Segment, and developed the Android library above.

f2prateek
  • 2,034
  • 2
  • 20
  • 26
0

As per this link, using messages and data items is the only way to work with Google Analytics on a wearable.

Eliezer
  • 7,209
  • 12
  • 56
  • 103