The Data Layer - Google Global Tag Manager
Looking at the Google tracking code for global site tag I was curious about the syntax ||.
|| in Javascript is a Logical OR.
What Google Developers webite says
The logical OR (||) (logical disjunction) operator
Looking at the Google tracking code:
The gtag() script:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-936952-6"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-936952-6');
</script>
The logical OR - || - instatiates the JavaScript Object dataLayer if the array is empty.
The object is populated by the gtag() function.
There is a lot going on with the gtag()