h2oai/google-analytics-java

Name: google-analytics-java

Owner: H2O.ai

Description: Java API for Google Analytics Measurement Protocol (part of Universal Analytics).

Created: 2015-04-09 22:27:31.0

Updated: 2018-04-23 13:46:20.0

Pushed: 2015-04-10 21:39:28.0

Homepage: null

Size: 407

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Java API for Google Analytics Measurement Protocol

Java API for Google Analytics Measurement Protocol (part of Universal Analytics). This library is released under liberal Apache Open source License 2.0

Google Analytics Measurement Protocol is new tracking protocol, which will replace the legacy Tracking protocol. This protocol is documented at https://developers.google.com/analytics/devguides/collection/protocol/v1/

The library is available in Maven Central. Add the following dependency and you are good to go.

<dependency>
    <groupId>com.brsanthu</groupId>
    <artifactId>google-analytics-java</artifactId>
    <version>1.1.1</version>
</dependency>

To get a local build, do

git clone https://github.com/brsanthu/google-analytics-java.git
mvn install

View Javadocs here http://brsanthu.github.io/google-analytics-java/javadocs/

Features

This library implements the measurement protocol with following features.

Version History

Version 1.1.1 - May 21 2014

Version 1.1.0 - Apr 22 2014

Version 1.0.5 - Apr 09 2014

Version 1.0.4 - Mar 3 2014

Version 1.0.3 - Jan 20 2014

Examples
GoogleAnalytics ga = new GoogleAnalytics("UA-12345678-1");
ga.post(new PageViewHit("https://www.google.com", "Google Search"));

Or

GoogleAnalytics ga = new GoogleAnalytics("UA-12345678-1");
ga.postAsync(new PageViewHit("https://www.google.com", "Google Search"));

Or

GoogleAnalytics ga = new GoogleAnalytics("UA-12345678-1");
ga.postAsync(new RequestProvider() {
    public GoogleAnalyticsRequest getRequest() {
        return new PageViewHit("https://www.google.com", "Google Search");
    }
});
Other Implementations

There are few Java implementation of Google Analytics api, but found some issues (or protocol mismatch) with each of them.

https://github.com/nhnopensource/universal-analytics-java

https://code.google.com/p/jgoogleanalyticstracker/

https://github.com/siddii/jgoogleanalytics


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.