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,9 +13,17 @@ if (!('customElements' in self)) {
} }
if (typeof PRERENDER === 'undefined') { 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)); window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args));
ga('create', 'UA-128752250-1', 'auto'); ga('create', 'UA-128752250-1', 'auto');
ga('set', 'transport', 'beacon'); ga('set', 'transport', 'beacon');
ga('set', 'dimension1', displayMode);
ga('send', 'pageview'); ga('send', 'pageview');
// Load the GA script // Load the GA script
const s = document.createElement('script'); const s = document.createElement('script');

View File

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