Git Product home page Git Product logo

datadog-ga's Introduction

datadog-ga

Datadog custom check for collecting Google Analytics Real Time data.

This custom check allows you to retrieve Google Analytics information from the Real Time API and send it as a regular metric to Datadog.

  • Support for multiple profiles (views)
  • Handles Active users (rt:activeUsers) and Pageviews (rt:pageviews) metrics
  • Allows for custom tagging for each profile
  • Allows for dimension-tag mapping for pageviews metric. Example: adding rt:country dimension, generate the #country: tag.

Installation

In order for the integration to work you must create a Service Account, obtain it's API key and give permission to access Analytics API by adding the Service Account e-mail to the Authorised users in that Property. If you are ready with this, go directly to Step 3: Installing the check.

Step 1 : Get a service account and API key

  1. Create a project
  2. Go to https://console.developers.google.com
  3. Upper right > Select a project
  4. Create a project or select an existing one
  5. Enable Google Analytics API
  6. In the left menu "API Manager", go to Overview
  7. In the search box type "analytics"
  8. Click on Analytics API
  9. Enable
  10. Create Access Credentials
  11. In the left menu "API Manager", go to Credentials
  12. Create credential > Service Account keys
  13. Select "New service account" and type in the name of it
  14. Select json for key file
  15. When done, don't forget to save the key json file
  16. Take note of service account email (ie: [email protected])

Step 2 : Authorize service account to query analytics

  1. Go into https://analytics.google.com and log in
  2. Go to Admin option in header menu
  3. Select the account you want to integrate. You may also select the specific property you want to give access.
  4. Goto to User Management
  5. Add permissions for the service account email address (Read & Analyze)
  6. Select the property and the view you wish to collect metrics from
  7. Take note of the View ID for later (ie: 12345678)

Step 3: Install the check (Finally!)

This steps are based on Ubuntu Linux.

  1. Clone or download from https://github.com/bithauschile/datadog-ga
  2. Install python libraries
  3. Use pip to install the Google API client for Python: /opt/datadog-agent/embedded/bin/pip install --upgrade google-api-python-client
  4. Install the check:
  • Copy ga.yaml to /etc/dd-agent/conf.d/
  • Copy ga.py to /etc/dd-agent/checks.d/
  • Copy the api key json file to the server in a directory the agent can access (ie: /etc/dd-agent/conf.d/)
  1. Configure by adding the account information and the properties (views) you want to integrate in /etc/dd-agent/conf.d/ga.yaml.
  • In the following example, the query divides the pageviews in 3 dimensions (country, city, device). For more information about available dimensions go to this page.
  • Be carefull with the min_collection_interval paramter. Google Analytics generate a by-minute result in the Real Time response with no timestamp. The only way to correlate Analytics data with the other metrics is running every 60 seconds aprox.
  init_config:
    min_collection_interval: 55
    service_account_email: [email protected]
    key_file_location: /opt/datadog-agent/etc/conf.d/key.json

  instances:

    - profile: ga:123456789
      tags:
       - env:test
      pageview_dimensions:
       - rt:country
       - rt:city
       - rt:deviceCategory 

Done!

Check that everything went right: /etc/init.d/datadog-agent check ga.

  • Restart the agent: /etc/init.d/datadog-agent restart.

##References

##Licence The code is licensed under the MIT License.

datadog-ga's People

Contributors

jmakuc avatar aleksandrpanteleymonov avatar

Watchers

Qubbaj 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.