Git Product home page Git Product logo

pebble-analytics's Introduction

pebble-analytics

Google Analytics implementation for Pebble smartwatch. Supports screen and event tracking. It uses the Google Analytics Measurement Protocol. Your Analytics property has to be a Mobile App Propery to work with this.

Usage

This project could be used as a demo of on the watch. Just download it, change the Analytics ID in pebble-js-app.js with your own, build and install. Whenn you press the UP, DOWN and SELECT buttons, you should see Events in your Google Analytics realtime view.

If you want to use it in your own project, take the following steps:

###App Configuration

If you are using tracking just in your JS app, there is no setup needed. You can read on in section a).

If you want to track screens direct on the watch, you have to set up App Message for the communication between Watch and JS. If you already did that, you need to set the nessecary keys by configuring them in your appinfo.json (see example).

"appKeys" : {
  "message_type" : 0,
  "track_screen_name" : 1,
  "track_event_category" : 2,
  "track_event_action" : 3
}

The trackScreen() and trackEvent() Functions in your C project will send messages with these keys to the JS app. There you will need to handle them and trigger the JS Functions as described in a) 1.

a) On the JS side

  1. Copy contents of pebble-ga.js to the beginning of pebble-js-app.js
  2. Initialize an analytics object like this: var ga = new Analytics('UA-1234567-0', 'myApp', '1.0.0');
  3. Track events or screens with ga.trackScreen('screen name'); or ga.trackEvent('category', 'action');
  4. (optional) If you use tracking on the Watch (C), then you need to handle the messages sent from there. See the pebble-js-app.js and search for appmessage to see how to do that.

b) On the C side

  1. Copy ga.h and ga.c to your src/ folder
  2. Include ga.h in your primary app file #include <ga.h>
  3. Set up app messages. E.g. by calling app_message_open(128, 128)
  4. Track events or screens with trackScreen("screen name"); or trackEvent("category", "action");

Keep in mind that you are responsible of handling messages. If you track to many times in a short interval on the watch, the messages could get lost. I recommend implementing some sort of message queue.

pebble-analytics's People

Contributors

flocsy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.