Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Isler committed Jul 24, 2018
2 parents 3cf32af + cd97930 commit 31101ab
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ accessing the data.
- This script is based on the deprecated `ga.js`, it is very likely that some day it will stop working.
Nevertheless, it will probably work for some more years since many websites are still actively using old GA versions.
- While I am not a lawyer myself, I suspect that using this script does violate most of Google's TOC as well as most
countries' data protection laws. I would strongly recommend to inform your users about your tracking activities and
perform a risk assessment.
countries' data protection laws. **Use at your own risk.**

If you are looking for a "compliant" solution, have a look at [this](https://github.com/dm-guy/utm-alternative/)
library, it replicates the tracking functionality of Google Analytics.
Expand All @@ -23,13 +22,26 @@ library, it replicates the tracking functionality of Google Analytics.
* `new GAParser([domains], limitRelevant = true)`

Returns a new instance.
`domains` must be an array of all domains you want to include in tracking.

# Methods

* `getInfo()`

Returns an object containing the parsed information.

```
{
userId: 'User ID',
initialVisit: 'Initial visit timestamp',
source: 'Source',
campaign: 'Campaign,
medium: 'Medium',
keywords: 'Keywords',
content: 'Content'
}
```

* `setCookie(name = '_ga-legacy-tracking')`

Sets a cookie containing a JSON string with parsed information.
Expand All @@ -41,10 +53,10 @@ Adds a hidden input to the specified form containing a JSON string with parsed i
# Usage

```
<!-- Add before </body> -->
<script src="../dist/ga-legacy-cookie-parser.min.js"></script>
<!-- Add before </body> for all domains you want to include in tracking -->
<script src="https://cdn.jsdelivr.net/gh/spiritix/[email protected]/dist/ga-legacy-cookie-parser.min.js"></script>
<script>
var parser = new GAParser(['app.local', 'second.com']);
var parser = new GAParser(['mydomain.com', 'second.com']);
console.log(parser.getInfo()); // Output info to console
parser.setCookie(); // Set info to cookie
parser.addToForm('test-form'); // Add info to form as hidden input
Expand All @@ -53,4 +65,4 @@ Adds a hidden input to the specified form containing a JSON string with parsed i

# License

GA Legacy Cookie Parser is free software distributed under the terms of the MIT license.
GA Legacy Cookie Parser is free software distributed under the terms of the MIT license.

0 comments on commit 31101ab

Please sign in to comment.