Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/SukkaW/cloudflare-workers-async-google-analytics

:cloud: The Cloudflare Workers implementation of an async Google Analytics
https://github.com/SukkaW/cloudflare-workers-async-google-analytics

cloudflare cloudflare-workers google-analytics

Last synced: 12 days ago
JSON representation

:cloud: The Cloudflare Workers implementation of an async Google Analytics

Awesome Lists containing this project

README

        

# cloudflare-workers-async-google-analytics

[![Author Sukka](https://img.shields.io/badge/author-Sukka-b68469.svg?style=flat-square)](https://skk.moe)
[![License MIT](https://img.shields.io/github/license/sukkaw/cloudflare-workers-async-google-analytics.svg?style=flat-square)](./LICENSE)
![NPM Version](https://img.shields.io/npm/v/cfga?style=flat-square)
[![Build with Cloudflare Workers](https://img.shields.io/badge/build%20with-cloudflare%20workers-f38020.svg?style=flat-square)](https://workers.cloudflare.com/)
![Gzip size of cfga.min.js](https://img.badgesize.io/sukkaw/cloudflare-workers-async-google-analytics/master/cfga.min.js.svg?compression=gzip&style=flat-square)
[![](https://data.jsdelivr.com/v1/package/npm/cfga/badge)](https://www.jsdelivr.com/package/npm/cfga)

The Cloudflare Workers implementation of an async Google Analytics

## Introduction

This project is based on [Google Analytics Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/v1/), using [Cloudflare Workers](https://workers.cloudflare.com/) with a less than 1KB gzipped tiny `cfga.min.js` to accelerate the Google Analytics, rather than a heavy (45KB gzipped) `analytics.js` from Google.

## Get Start

### 1. Import into Cloudflare Workers

Login into Cloudflare Dashboard and enter `Workers` App. Create a new script, delete default code in the editor, and then copy [the `woker.js` content](https://github.com/SukkaW/cloudflare-workers-async-google-analytics/blob/master/worker.js) into the editor. After saving the workers script, do not forget to register a route for the scripts.

Now you can test your workers with a simple HTTP request. You should able to see `403 Forbidden`. Then you can deploy the scripts.

### 2. Insert the `cfga.min.js` into your website

Just add those few lines of the code to your website, right before `