Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Isler committed Jul 24, 2018
1 parent ca29526 commit 8070941
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Adds a hidden input to the specified form containing a JSON string with parsed i

```
<!-- Add before </body> for all domains you want to include in tracking -->
<script src="https://cdn.jsdelivr.net/gh/spiritix/[email protected].0/dist/ga-legacy-cookie-parser.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/spiritix/[email protected].1/dist/ga-legacy-cookie-parser.min.js"></script>
<script>
var parser = new GAParser(['mydomain.com', 'second.com']);
console.log(parser.getInfo()); // Output info to console
Expand Down
2 changes: 1 addition & 1 deletion dist/ga-legacy-cookie-parser.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/ga-legacy-cookie-parser.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "GA Legacy Cookie Parser",
"name": "ga-legacy-cookie-parser-js",
"version": "0.2.0",
"version": "0.2.1",
"author": "Matthias Isler <[email protected]>",
"description": "A workaround for accessing GA data in Universal Analytics environments.",
"keywords": [
Expand Down
17 changes: 9 additions & 8 deletions src/ga-legacy-cookie-parser.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*!
* GA Legacy Cookie Parser v0.2.0
* GA Legacy Cookie Parser v0.2.1
*
* A workaround for accessing GA data in Universal Analytics environments.
* https://github.com/spiritix/ga-legacy-cookie-parser
*
* Copyright © Matthias Isler <[email protected]>
* Licensed under MIT
*/
/* globals exports, module, define */
(function (window, undefined) {
'use strict';

Expand Down Expand Up @@ -50,7 +51,7 @@
name = links[i].href;
}

if (onClick != null) {
if (onClick !== null) {
onClick = String(onClick);

if (onClick.indexOf('_gasf.push') > -1) {
Expand All @@ -59,10 +60,10 @@
}

for (var j = 0; j < domains.length; j++) {
if (name != hostname && name.indexOf(domains[j]) != -1 && name.indexOf('mailto:') == -1) {
if (name !== hostname && name.indexOf(domains[j]) !== -1 && name.indexOf('mailto:') == -1) {

links[i].setAttribute('onclick',
'' + ((onClick != null) ? onClick + '; ' : '') +
'' + ((onClick !== null) ? onClick + '; ' : '') +
"_gaq.push(['xxga._link', '" + links[i].href + "']); return false;"
);
}
Expand Down Expand Up @@ -100,7 +101,7 @@
info.domainHash = content[0];
info.pageViews = content[1] && Number(content[1]);
info.outboundClick = content[2] && Number(content[2]);
info.currentVisit = content[3] && Number(content[3])
info.currentVisit = content[3] && Number(content[3]);
}
else if (type === 'utmc') {
info.domainHash = content[0];
Expand All @@ -119,9 +120,9 @@
param = param.split('=');

try {
info[param[0]] = global.unescape(/^\(.*\)$/.test(param[1]) ?
param[1].replace(/^\(?(.*?)\)?$/, '$1') :
param[1]);
info[param[0]] = decodeURI(
/^\(.*\)$/.test(param[1]) ? param[1].replace(/^\(?(.*?)\)?$/, '$1') : param[1]
);
}
catch (e) {
info[param[0]] = param[1];
Expand Down
2 changes: 1 addition & 1 deletion test/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</head>
<body>
<a href="https://www.google.com">Google</a>
<a href="https://second.com" target="_blank">Other</a>
<a href="https://second.com/folder-a/?param=a87XA&b=2" target="_blank">Other</a>
<form id="test-form"></form>
<script src="../dist/ga-legacy-cookie-parser.min.js"></script>
<script>
Expand Down

0 comments on commit 8070941

Please sign in to comment.