Data Layer
Menu The Data Layer
 

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

" A data layer is a JavaScript object that is used to pass information from your website to your Tag Manager container. You can then use that information to populate variables and activate triggers in your tag configurations. ... Transaction data: Cart value, checkout date. Customer information: New or returning customer. "

Top

The logical OR (||) (logical disjunction) operator

" The logical OR (||) (logical disjunction) operator for a set of operands is true if and only if one or more of its operands is true. It is typically used with boolean (logical) values. When it is, it returns a Boolean value. However, the || operator actually returns the value of one of the specified operands, so if this operator is used with non-Boolean values, it will return a non-Boolean value. "

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()

Links

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links toother websites.

The External link is disabled to on this page, please visit other pages

Unlike most genealogical research websites tempusfugit.me.uk does not attempt to get you to "sign-up" when you click on one of their links.

This Wikipedia link is disabled.

The link on Wikipedia was to:

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links to other websites.

The External link is disabled to on this page, please visit other pages

Top

External Links - references

Site design by Tempusfugit Web Design -