Coder Social home page Coder Social logo

eyyminda / ab-analytics Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 833 KB

Initial Steps towards a custom A/B Testing platform using data from Google Analytics.

Home Page: https://ab-analytics.vercel.app

JavaScript 86.91% HTML 1.50% CSS 11.58%
ab-testing expressjs google-analytics-4 reactjs vite google-cloud

ab-analytics's Introduction

React + Vite + Express

Minimal setup for a custom A/B testing application using Google Cloud and data from Google Analytics.

Preview

Preview

Usage

  • Select a start date, end date, and metric from the form.
  • Click the "Fetch" button to retrieve data from Google Analytics.
  • The table will display the data for the selected date range and metric, grouped by country.
  • The sum total of the chosen metric is displayed in a separate box.

Google Cloud + GA Setup

Google Analytics Property ID:

property-id

  • You'll see the ID there

Create Google Cloud Credentials and Enable API (Google Analytics Data API)

  • Navigate to API's & Services, Credentials

api-credentials

  • Create Credentials (OAuth)

create-credentials

  • Enter url's that you're using for your application server (vite uses 5173 by default)

urls

ENV

Create a .env file in the project root directory and populate it with the following variables:

PROPERTY_ID=YOUR_GOOGLE_ANALYTICS_PROPERTY_ID
PORT=3000
VITE_PORT=3000
GOOGLE_APPLICATION_CREDENTIALS_JSON=YOUR_SERVICE_ACCOUNT_KEY_JSON
Replace YOUR_GOOGLE_ANALYTICS_PROPERTY_ID with your Google Analytics property ID, and YOUR_SERVICE_ACCOUNT_KEY_JSON with the contents of your service account key JSON file. Additional VITE_PORT is needed for frontend to contact backend.

E.g.:

PROPERTY_ID=12345678
PORT=3000
VITE_PORT=3000
GOOGLE_APPLICATION_CREDENTIALS_JSON={"type": "service_account", "project_id": "dashboard1-1682805546629", "private_key_id": "blablabla\n-----END PRIVATE KEY-----\n", "client_email": "client-email-here", "client_id": "1234", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.somelink.com"}

Start the development server:

npm start

Contents

ExpressJs (Back-end Server) file

/api/index.js

Dashboard (GA data fetch example)

Uses Tailwind instead

``Pages``
/src/pages/main/Dashboard.jsx

``Components``
/src/components/Abs/Table.jsx

AB content

Uses Style Components (Prefered)

``Pages``
/src/pages/main/ActiveAb.jsx
/src/pages/main/AllAb.jsx
/src/pages/main/NewAb.jsx

``Components``
/src/components/Abs/AbList.jsx
/src/components/Abs/AbItem.jsx
/src/components/Abs/NewAbForm.jsx

``Context``
/src/setup/ab-context.js

Unused utility

/src/setup/google-analytics.js

ab-analytics's People

Contributors

dependabot[bot] avatar eyyminda avatar imgbotapp avatar

Stargazers

 avatar  avatar

Watchers

 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.