# workers-google-analytics
**Repository Path**: mirrors_cloudflare/workers-google-analytics
## Basic Information
- **Project Name**: workers-google-analytics
- **Description**: Middleware for Google Analytics tracking in Workers
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-10-29
- **Last Updated**: 2026-02-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# workers-google-analytics
Middleware for proxying Google Analytics pageviews via Workers
## Usage
Install the package and include it in your Cloudflare Workers code. You should pass in a list of origins that will be whitelisted for sending Analytics events to your Google Analytics account.
```sh
$ yarn add workers-google-analytics
```
```js
// index.js
import analytics from 'workers-google-analytics'
const analyticsResp = await analytics(event, {
allowList: ['bytesized.xyz'],
})
if (analyticsResp) return analyticsResp
```
In the `head` section of your web application, load the script helper and begin sending analytics events:
```html
```
## Custom script helper
The provided script helper deployed at `ga-helper.developers.workers.dev` is an example -- while you _can_ use it in production, we can't promise that it won't eventually be blocked by uBlock and other similar tools.
To mitigate this, the Workers code for that domain is available in the [`helper` directory](https://github.com/signalnerve/workers-google-analytics/tree/main/helper). You can take that code and deploy it to your own workers.dev subdomain (or a custom domain) and use it accordingly.