forked from DjangoGirls/djangogirls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Google Tag Manager and cookie consent
- Loading branch information
1 parent
c77bca1
commit 754572e
Showing
3 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<div id="cookieModal" class="modal fade" role="dialog"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">We value your privacy</h5> | ||
</div> | ||
<div class="modal-body"> | ||
<p>We use cookies on this website to enhance your user experience. By clicking "I agree", you are giving your consent for us to set cookies.</p> | ||
<p>For more information on what data is contained in the cookies, please see our <a href="/privacy-cookies/">Privacy Policy</a> page.</p> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="rejectCookies">I decline</button> | ||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="acceptCookies">I agree</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
$(document).ready(function(){ | ||
// Cookie consent functions | ||
function setCookie(name, value, days) { | ||
var expires = ""; | ||
if (days) { | ||
var date = new Date(); | ||
date.setTime(date.getTime() + (days*24*60*60*1000)); | ||
expires = "; expires=" + date.toUTCString(); | ||
} | ||
document.cookie = name + "=" + (value || "") + expires + "; path=/"; | ||
} | ||
|
||
function getCookie(name) { | ||
var nameEQ = name + "="; | ||
var ca = document.cookie.split(';'); | ||
for(var i=0;i < ca.length;i++) { | ||
var c = ca[i]; | ||
while (c.charAt(0)==' ') c = c.substring(1,c.length); | ||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); | ||
} | ||
return null; | ||
} | ||
|
||
// Show cookie consent modal if not accepted yet | ||
if(getCookie('cookiesAccepted') === null){ | ||
$('#cookieModal').modal('show'); | ||
} | ||
|
||
// Handle cookie consent choices | ||
$('#acceptCookies').on('click', function(){ | ||
setCookie('cookiesAccepted', 'true', 365); | ||
}); | ||
|
||
$('#rejectCookies').on('click', function(){ | ||
setCookie('cookiesAccepted', 'false', 365); | ||
}); | ||
}); | ||
</script> |