https://github.com/methodgrab/ga-clean-urls
A plugin for Google Analytics to remove UTM query strings from URLs
https://github.com/methodgrab/ga-clean-urls
google-analytics google-analytics-plugin
Last synced: 3 months ago
JSON representation
A plugin for Google Analytics to remove UTM query strings from URLs
- Host: GitHub
- URL: https://github.com/methodgrab/ga-clean-urls
- Owner: MethodGrab
- License: mit
- Created: 2016-08-30T16:51:09.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T16:23:37.000Z (over 3 years ago)
- Last Synced: 2025-03-22T10:24:07.361Z (3 months ago)
- Topics: google-analytics, google-analytics-plugin
- Language: JavaScript
- Size: 101 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Google Analytics Plugin: Clean URLs [](https://travis-ci.org/MethodGrab/ga-clean-urls) [](https://www.npmjs.com/package/ga-clean-urls) 
> A plugin for Google Analytics to remove UTM query strings from URLsThis plugin is heavily inspired by Wistia's [Fresh URL](https://wistia.com/blog/fresh-url) [library](https://github.com/wistia/fresh-url) but I wanted something more minimal so I've implemented its core functionality as a [Google Analytics plugin](https://developers.google.com/analytics/devguides/collection/analyticsjs/writing-plugins).
Before:
```
https://example.com/article/?utm_source=twitter&utm_medium=tweet&utm_campaign=website&foo=bar
```After:
```
https://example.com/article/?foo=bar
```---
### Warning:
This module is pre-1.0 and has not been thoroughly tested. Please test it yourself before using it in a production environment. Bugs can be reported on the [issue tracker](https://github.com/methodgrab/ga-clean-urls/issues).---
## Install
```bash
npm install --save ga-clean-urls
```## Usage
The plugin must be loaded **after** the 'pageview' send so the UTM parameters are tracked correctly.```html
ga( 'create', 'UA-XXXXX-Y', 'auto' );
ga( 'send', 'pageview' );// Require the plugin after 'pageview' send
ga( 'require', 'cleanUrls' );```
## Browser support
IE10+.The plugin uses `history.replaceState` to manipulate the URL, if the browser does not support `history.replaceState` then it shouldn't cause any problems but the URL will remain unchanged.
See http://caniuse.com/#feat=history for detailed browser support.## Todo
- [ ] Add tests