-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added notification when user first visits the site - Notification provides options to opt-out of analytics - Notification can be redisplayed by clicking on the "Privacy" link at the bottom of every page - Client-only cookie used to maintain user setting. - Removed non-essential npm bundles. - Dev environment contains one vulnerability due to transitive dependency (less). This dependency is only used when generating the static site and is required.
- Loading branch information
Showing
9 changed files
with
3,468 additions
and
8,024 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
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
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
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 |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<div id="gdpr" class="hide navbar-fixed-bottom footer"> | ||
<h3>Privacy Policy</h3> | ||
We value and respect your privacy. Analytics is used to track consumers of our site and improve its content. We do | ||
not share, nor sell data to third parties, nor link to any personal information on the collected data. | ||
Thank you for your interest in NATS. | ||
</p> | ||
<form> | ||
<div> | ||
<div class="checkbox"> | ||
<label><input id="disable_analytics" value="true" type="checkbox">Disable analytics</label> | ||
</div> | ||
<span class="pull-right"> | ||
<button type="button" class="btn btn-success" onclick="gdprOK()">OK</button> | ||
</span> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<script> | ||
function getGAKey() { | ||
return "UA-111730698-1"; | ||
} | ||
|
||
function getGAKeyDisableKey() { | ||
return "ga-disable-" + getGAKey(); | ||
} | ||
function getCookie() { | ||
var cookies = document.cookie; | ||
var a = cookies.split(";"); | ||
return a.find(function (e) { | ||
e = e.trim(); | ||
return e.startsWith("ga-disable="); | ||
}); | ||
} | ||
|
||
function updateCheckbox(tc) { | ||
// set the state of the html to match in case the preview it | ||
var checked = false; | ||
if (tc) { | ||
checked = tc.trim().split('=')[1] === "true"; | ||
} | ||
$('#disable_analytics').prop('checked', checked); | ||
} | ||
|
||
function addGA() { | ||
// now load google analytics script | ||
if (!$('#gascript').length) { | ||
var s = document.createElement('script', {async: '', id: 'gascript'}); | ||
s.type = 'text/javascript'; | ||
s.src = 'https://www.google-analytics.com/analytics.js'; | ||
$('body').append(s); | ||
} | ||
} | ||
|
||
function checkTrack() { | ||
var tc = getCookie(); | ||
updateCheckbox(tc); | ||
|
||
// set it up early | ||
var disable = $('#disable_analytics').is(':checked'); | ||
window[getGAKeyDisableKey()] = disable; | ||
|
||
if (!tc) { | ||
openPrivacy(tc); | ||
} else { | ||
var disable = tc.trim().split('=')[1] === "true"; | ||
// set a property on the window to disable ga | ||
// https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out | ||
window[getGAKeyDisableKey()] = disable; | ||
addGA(); | ||
} | ||
} | ||
|
||
function openPrivacy(tc) { | ||
var sel = $('#gdpr'); | ||
sel.removeClass('hide'); | ||
var height = sel.outerHeight(); | ||
$('body').css('padding-bottom', height + "px"); | ||
return false; | ||
} | ||
|
||
|
||
function oneYearFromNow() { | ||
var d = new Date(); | ||
d.setFullYear(d.getFullYear() + 1); | ||
return d; | ||
} | ||
|
||
function gdprOK() { | ||
var disable = $('#disable_analytics').is(':checked'); | ||
window[getGAKeyDisableKey()] = disable; | ||
$('#gdpr').addClass('hide'); | ||
$('body').css('padding-bottom', '0px'); | ||
var d = new Date(); | ||
d.setFullYear(d.getFullYear() + 1); | ||
document.cookie = "ga-disable=" + disable + "; expires=" + oneYearFromNow().toUTCString() + "; path=/"; | ||
addGA(); | ||
} | ||
</script> |
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
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 |
---|---|---|
@@ -1,6 +1,29 @@ | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> | ||
|
||
<script> | ||
$(document).ready(function() { | ||
checkTrack(); | ||
}); | ||
|
||
$('#priv').on('click', function(e) { | ||
openPrivacy(); | ||
}); | ||
|
||
</script> | ||
|
||
|
||
<script src="/js/index.js"></script> | ||
<!-- Github Buttons --> | ||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
<!-- Google Analytics --> | ||
{{ template "_internal/google_analytics.html" . }} | ||
|
||
|
||
<!-- Google Analytics Configuration - scripts added dynamically after user opts in or out--> | ||
<script> | ||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; | ||
ga('create', getGAKey(), { | ||
cookieExpires: 0 | ||
}); | ||
ga('set', 'anonymizeIp', true); | ||
ga('send', 'pageview'); | ||
</script> | ||
<!-- End Google Analytics --> |
Oops, something went wrong.