mirror of
https://github.com/ascribe/wp-theme
synced 2024-12-22 09:13:38 +01:00
refined Google Analytics loading, respecting DNT
This commit is contained in:
parent
247ec05ae5
commit
7a6f3c3539
46
assets/_src/js/_dnt.js
Normal file
46
assets/_src/js/_dnt.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Returns true or false based on whether doNotTack is enabled. It also takes into account the
|
||||||
|
* anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles
|
||||||
|
* IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec.
|
||||||
|
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details
|
||||||
|
* @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing.
|
||||||
|
* @params {string} [userAgent] - An optional mock userAgent string to ease unit testing.
|
||||||
|
* @returns {boolean} true if enabled else false
|
||||||
|
*/
|
||||||
|
function _dntEnabled(dnt, userAgent) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// for old version of IE we need to use the msDoNotTrack property of navigator
|
||||||
|
// on newer versions, and newer platforms, this is doNotTrack but, on the window object
|
||||||
|
// Safari also exposes the property on the window object.
|
||||||
|
var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
|
||||||
|
var ua = userAgent || navigator.userAgent;
|
||||||
|
|
||||||
|
// List of Windows versions known to not implement DNT according to the standard.
|
||||||
|
var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3'];
|
||||||
|
|
||||||
|
var fxMatch = ua.match(/Firefox\/(\d+)/);
|
||||||
|
var ieRegEx = /MSIE|Trident/i;
|
||||||
|
var isIE = ieRegEx.test(ua);
|
||||||
|
// Matches from Windows up to the first occurance of ; un-greedily
|
||||||
|
// http://www.regexr.com/3c2el
|
||||||
|
var platform = ua.match(/Windows.+?(?=;)/g);
|
||||||
|
|
||||||
|
// With old versions of IE, DNT did not exist so we simply return false;
|
||||||
|
if (isIE && typeof Array.prototype.indexOf !== 'function') {
|
||||||
|
return false;
|
||||||
|
} else if (fxMatch && parseInt(fxMatch[1], 10) < 32) {
|
||||||
|
// Can't say for sure if it is 1 or 0, due to Fx bug 887703
|
||||||
|
dntStatus = 'Unspecified';
|
||||||
|
} else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) {
|
||||||
|
// default is on, which does not honor the specification
|
||||||
|
dntStatus = 'Unspecified';
|
||||||
|
} else {
|
||||||
|
// sets dntStatus to Disabled or Enabled based on the value returned by the browser.
|
||||||
|
// If dntStatus is undefined, it will be set to Unspecified
|
||||||
|
dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified';
|
||||||
|
}
|
||||||
|
|
||||||
|
return dntStatus === 'Enabled' ? true : false;
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
|
|
||||||
|
//=include _dnt.js
|
||||||
//=include _faq.js
|
//=include _faq.js
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
Faq.init();
|
if ( $('.subtemplate--faq').length ) {
|
||||||
|
Faq.init();
|
||||||
|
}
|
||||||
|
|
||||||
slider();
|
slider();
|
||||||
marketplaces();
|
marketplaces();
|
||||||
|
2
assets/dist/js/ascribe.js
vendored
2
assets/dist/js/ascribe.js
vendored
File diff suppressed because one or more lines are too long
2
assets/dist/js/ascribe.min.js
vendored
2
assets/dist/js/ascribe.min.js
vendored
File diff suppressed because one or more lines are too long
122
footer.php
122
footer.php
@ -165,65 +165,99 @@ if ($twitter) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<div class="chevron-divider"></div>
|
<div class="chevron-divider"></div>
|
||||||
|
|
||||||
|
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
|
|
||||||
<section class="footer__top">
|
<section class="footer__top">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
|
||||||
<?php wp_nav_menu( array( 'theme_location' => 'main-footer-menu', 'container' => false ) ); ?>
|
<?php wp_nav_menu( array( 'theme_location' => 'main-footer-menu', 'container' => false ) ); ?>
|
||||||
|
|
||||||
<div class="footer__contact">
|
<div class="footer__contact">
|
||||||
|
|
||||||
<?php if ($footerContactButton) { ?>
|
<?php if ($footerContactButton) { ?>
|
||||||
<a href="<?php echo $consultLink; ?>" class="button small"><?php echo $footerContactButton ?></a>
|
<a href="<?php echo $consultLink; ?>" class="button small"><?php echo $footerContactButton ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<div><?php echo $address; ?></div>
|
||||||
|
<div><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div><?php echo $address; ?></div>
|
|
||||||
<div><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
</div>
|
<section class="footer__bottom">
|
||||||
</section>
|
<div class="row">
|
||||||
|
|
||||||
<section class="footer__bottom">
|
<div class="footer__eu">
|
||||||
<div class="row">
|
<?php if ($euLink) { ?>
|
||||||
|
<a href="<?php echo $euLink ?>">
|
||||||
<div class="footer__eu">
|
<img width="150" src="https://www.ascribe.io/wp-content/uploads/2015/11/eu-dev-fund.png" />
|
||||||
<?php if ($euLink) { ?>
|
</a>
|
||||||
<a href="<?php echo $euLink ?>">
|
<?php } else { ?>
|
||||||
<img width="150" src="https://www.ascribe.io/wp-content/uploads/2015/11/eu-dev-fund.png" />
|
<img width="150" src="https://www.ascribe.io/wp-content/uploads/2015/11/eu-dev-fund.png" />
|
||||||
</a>
|
<?php } ?>
|
||||||
<?php } else { ?>
|
</div>
|
||||||
<img width="150" src="https://www.ascribe.io/wp-content/uploads/2015/11/eu-dev-fund.png" />
|
|
||||||
<?php } ?>
|
<div class="footer__copyright">© <?php echo $year; ?> ascribe GmbH</div>
|
||||||
|
|
||||||
|
<?php wp_nav_menu( array( 'theme_location' => 'lower-footer-menu', 'container' => false ) ); ?>
|
||||||
|
|
||||||
|
<ul class="footer__social">
|
||||||
|
<?php echo $facebook; ?>
|
||||||
|
<?php echo $github; ?>
|
||||||
|
<?php echo $instagram; ?>
|
||||||
|
<?php echo $linkedin; ?>
|
||||||
|
<?php echo $medium; ?>
|
||||||
|
<?php echo $reddit; ?>
|
||||||
|
<?php echo $tumblr; ?>
|
||||||
|
<?php echo $twitter; ?>
|
||||||
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="footer__copyright">© <?php echo $year; ?> ascribe GmbH</div>
|
</footer>
|
||||||
|
|
||||||
<?php wp_nav_menu( array( 'theme_location' => 'lower-footer-menu', 'container' => false ) ); ?>
|
|
||||||
|
|
||||||
<ul class="footer__social">
|
|
||||||
<?php echo $facebook; ?>
|
|
||||||
<?php echo $github; ?>
|
|
||||||
<?php echo $instagram; ?>
|
|
||||||
<?php echo $linkedin; ?>
|
|
||||||
<?php echo $medium; ?>
|
|
||||||
<?php echo $reddit; ?>
|
|
||||||
<?php echo $tumblr; ?>
|
|
||||||
<?php echo $twitter; ?>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php wp_footer(); ?>
|
|
||||||
|
<?php wp_footer(); ?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (!_dntEnabled()) {
|
||||||
|
(function(window) {
|
||||||
|
|
||||||
|
// Google Analytics async snippet
|
||||||
|
// http://goo.gl/3FPNDx
|
||||||
|
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};
|
||||||
|
ga.l=+new Date;
|
||||||
|
|
||||||
|
// Create the GA tracker
|
||||||
|
ga('create', 'UA-60614729-2', 'auto', {siteSpeedSampleRate: 10});
|
||||||
|
|
||||||
|
// Send initial pageview
|
||||||
|
ga('send', 'pageview');
|
||||||
|
|
||||||
|
// Track uncaught errors
|
||||||
|
window.onerror = function(message, url, line, col) {
|
||||||
|
var desc = message + ' (line: ' + line + ', url: ' + url + ', col: '
|
||||||
|
+ col + ')';
|
||||||
|
|
||||||
|
ga('send', 'exception', {
|
||||||
|
exDescription: 'window.onerror: ' + desc,
|
||||||
|
exFatal: false
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
}(window));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script async src="//www.google-analytics.com/analytics.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
21
header.php
21
header.php
@ -22,17 +22,21 @@ if ( is_category() || is_tag() ) {
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html class="no-js " lang="en" itemscope itemtype="https://schema.org/Organization" xmlns="http://www.w3.org/1999/html">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
|
|
||||||
<title><?php echo $title ?></title>
|
<title><?php echo $title ?></title>
|
||||||
<base href="<?php echo $url; ?>">
|
<base href="<?php echo $url; ?>">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0">
|
|
||||||
<meta name="description" content="<?php echo $description ?>">
|
<meta name="description" content="<?php echo $description ?>">
|
||||||
|
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="HandheldFriendly" content="True">
|
||||||
|
<meta name="MobileOptimized" content="320">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta http-equiv="cleartype" content="on">
|
||||||
|
|
||||||
<meta property="og:title" content="<?php echo $title; ?>" />
|
<meta property="og:title" content="<?php echo $title; ?>" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:url" content="<?php echo $permalink; ?>" />
|
<meta property="og:url" content="<?php echo $permalink; ?>" />
|
||||||
@ -72,17 +76,6 @@ if ( is_category() || is_tag() ) {
|
|||||||
})(document);
|
})(document);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
||||||
|
|
||||||
ga('create', 'UA-60614729-2', 'auto');
|
|
||||||
ga('send', 'pageview');
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php wp_head(); ?>
|
<?php wp_head(); ?>
|
||||||
</head>
|
</head>
|
||||||
<body <?php body_class($headColour); ?> >
|
<body <?php body_class($headColour); ?> >
|
||||||
|
Loading…
Reference in New Issue
Block a user