Merge pull request #765 from petele/dimension

This commit is contained in:
Surma
2020-06-24 16:15:16 +01:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@@ -13,11 +13,19 @@ if (!('customElements' in self)) {
}
if (typeof PRERENDER === 'undefined') {
// Determine the current display mode.
let displayMode = 'browser';
const mqStandAlone = '(display-mode: standalone)';
if (navigator.standalone || window.matchMedia(mqStandAlone).matches) {
displayMode = 'standalone';
}
// Setup analytics
window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args));
ga('create', 'UA-128752250-1', 'auto');
ga('set', 'transport', 'beacon');
ga('set', 'dimension1', displayMode);
ga('send', 'pageview');
// Load the GA script
// Load the GA script
const s = document.createElement('script');
s.src = 'https://www.google-analytics.com/analytics.js';
document.head!.appendChild(s);

View File

@@ -39,3 +39,7 @@ declare var ga: {
(...args: any[]): void;
q: any[];
};
interface Navigator {
readonly standalone: boolean;
}