mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-11 23:55:16 +01:00
better GA async snippet, load debug version in dev
This commit is contained in:
parent
6676810f7a
commit
d5615b96bf
@ -52,29 +52,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="/assets/js/kremalicious3.min.js" async></script>
|
{% include scripts.html %}
|
||||||
|
|
||||||
{% if jekyll.environment == "production" %}
|
|
||||||
<script>
|
|
||||||
var _paq = _paq || [];
|
|
||||||
_paq.push(['trackPageView']);
|
|
||||||
_paq.push(['enableLinkTracking']);
|
|
||||||
(function() {
|
|
||||||
var u="//analytics.kremalicious.com/";
|
|
||||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
|
||||||
_paq.push(['setSiteId', 1]);
|
|
||||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
|
||||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<noscript><p><img src="//analytics.kremalicious.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
|
||||||
|
|
||||||
<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-1441794-2', 'auto');
|
|
||||||
ga('send', 'pageview');
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
|
49
_src/_includes/scripts.html
Normal file
49
_src/_includes/scripts.html
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<script src="/assets/js/kremalicious3.min.js" async></script>
|
||||||
|
|
||||||
|
{% if jekyll.environment == "production" %}
|
||||||
|
<script>
|
||||||
|
var _paq = _paq || [];
|
||||||
|
_paq.push(['trackPageView']);
|
||||||
|
_paq.push(['enableLinkTracking']);
|
||||||
|
(function() {
|
||||||
|
var u="//analytics.kremalicious.com/";
|
||||||
|
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||||
|
_paq.push(['setSiteId', 1]);
|
||||||
|
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||||
|
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<noscript><p><img src="//analytics.kremalicious.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(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-1441794-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>
|
||||||
|
|
||||||
|
{% if jekyll.environment == "production" %}
|
||||||
|
<script async src="//www.google-analytics.com/analytics.js"></script>
|
||||||
|
{% else %}
|
||||||
|
<script async src="//www.google-analytics.com/analytics_debug.js"></script>
|
||||||
|
{% endif%}
|
Loading…
Reference in New Issue
Block a user