Coder Social home page Coder Social logo

gatsby-source-google-analytics-reporting-api's Introduction

Gatsby source for Google Anatytics Reporting API

Install

npm i gatsby-source-google-analytics-reporting-api

Configure

In gatsby-config.js:

    {
      resolve: `gatsby-source-google-analytics-reporting-api`,
      options: {
        email: process.env.CLIENT_EMAIL,
        key: require('fs').readFileSync('private.key'),
        viewId: `115350264`,
        startDate: `2009-01-01`,
      }
    },

Usage

    pageViews(path: {eq: $slug}) {
      totalCount
    }

License

MIT

gatsby-source-google-analytics-reporting-api's People

Contributors

antonmedv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gatsby-source-google-analytics-reporting-api's Issues

Google Analytics v4

It's 6+ months out, but Google Analytics v4 is here and starting July 1, 2023, we won't be able to use the current properties:

https://support.google.com/analytics/answer/10089681?hl=en

On July 1, 2023, standard Universal Analytics properties will no longer process data. You'll be able to see your Universal Analytics reports for a period of time after July 1, 2023. However, new data will only flow into Google Analytics 4 properties.

403 issue

Hi, thanks for making this plugin!
I'm having trouble implementing it. I've read many resources on how to use google APIs before submitting this ticket, I just can't get it to work. My issue is that I keep getting a 403 error when I run gatsby develop:

Error: Request failed with status code 403

  - createError.js:16 createError
    [lengjai]/[axios]/lib/core/createError.js:16:15

  - settle.js:18 settle
    [lengjai]/[axios]/lib/core/settle.js:18:12

  - http.js:201 Unzip.handleStreamEnd
    [lengjai]/[axios]/lib/adapters/http.js:201:11

  - next_tick.js:63 process._tickCallback
    internal/process/next_tick.js:63:19

gatsby-config.js

{
      resolve: `gatsby-source-google-analytics-reporting-api`,
      options: {
        email: '[email protected]',
        key: '-----BEGIN PRIVATE KEY-----\ there's a lot inside of this key==\n-----END PRIVATE KEY-----\n',
        viewId: `000000000`,
        startDate: `2017-01-01`,
      }
    },

So I registered for the google reporting API and downloaded the key info as JSON when it prompted me to. Inside the JSON file I had all the information such as private key and client email. I removed those in my code for privacy. I gathered the viewId from my google analytics page. So I have a couple things that could potentially cause the issue:

  1. Maybe my private key is wrong? It is insanely massive and has \n line breaks scattered along with that BEGIN PRIVATE KEY statement.
  2. The plugin is outdated? The latest Analytics reporting API is in v4.

Thanks!
Sean

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.