Code Monkey home page Code Monkey logo

embulk-input-google_analytics's Introduction

CircleCI Code Climate Test Coverage Issue Count Gem Version

Google Analytics input plugin for Embulk

Embulk input plugin for Google Analytics reports.

Configuration

  • json_key_content: See example config.
  • view_id: View ID for target data. See Get View ID (string, required)
  • time_series: Only ga:dateHour or ga:date (string, required)
  • dimensions: Target dimensions (array, default: [] )
  • metrics: Target metrics (array, default: [] )
  • start_date: Target report start date. Valid format is "YYYY-MM-DD". (string, default: 7 days ago)
  • end_date: Target report end date. Valid format is "YYYY-MM-DD". (string, default: 1 day ago)
  • incremental: true for generate "config_diff" with embulk run -c config.diff (bool, default: true)
  • last_record_time: Ignore fetched records until this time. Mainly for incremental:true. (string, default: nil)
  • retry_limit: Try to retry this times (integer, default: 5)
  • retry_initial_wait_sec: Wait seconds for exponential backoff initial value (integer, default: 2)

Get View ID

  1. Go to the Google Analytics sign in page and sign in.
  2. Click "Admin" tab at left below
  3. Select the "Property" using the drop-down menu below ‘Property’.
  4. Select ‘View Settings’ beneath ‘View’.
  5. The View ID for the selected property is listed first under ‘Basic Settings

About json_key_content option.

You need a service account on Google.

  1. Open the Service accounts page. If prompted, select a project.
  2. Click Create service account.
  3. In the <b>Create service account</b> window, type a name for the service
    account, and select <b>Furnish a new private key</b>. If you want to
    <a href="https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority">grant
    Google Apps domain-wide authority</a> to the service account, also select
    <b>Enable Google Apps Domain-wide Delegation</b>.
    
    Then click <b>Create</b>.</li>
    
From:

Screenshot: Service Account

Why the result doesn't match with web interface?

Google Reporting API uses "sampling" data.

That means sometimes result will be unmatched with Google Analytics web interface, and the result is based on sampled data, not all of raw data. This is a Google API's limitation.

Currently a sampling level supported by this plugin is DEFAULT only. Let us know if you want to use other sampling level (SMALL or LARGE).

Example

in:
  type: google_analytics
  json_key_content: |
    {
      "type": "service_account",
      "project_id": "....",
      "private_key_id": "....",
      "private_key": "-----BEGIN PRIVATE KEY-----\n..........................\n-----END PRIVATE KEY-----\n",
      "client_email": ".....",
      "client_id": ".........",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "token_uri": "https://accounts.google.com/o/oauth2/token",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
      "client_x509_cert_url": ".........."
    }
  view_id: 123111111
  time_series: "ga:dateHour" # hourly basis
 
  # https://developers.google.com/analytics/devguides/reporting/core/dimsmets
  dimensions:
    - "ga:browser"
  metrics:
    - "ga:visits"
    - "ga:pageviews"

  start_date: "2016-06-27"
  end_date: "2016-06-28"

Build

$ rake

embulk-input-google_analytics's People

Contributors

uu59 avatar muga avatar sakama avatar thangnc avatar kazuya030 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.