-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/spiritix/ga-legacy-cookie…
- Loading branch information
Showing
1 changed file
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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. | ||
|
@@ -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 | ||
|
@@ -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. |