GTM Data Layer
This JavaScript is added in the header of the website:
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
The dataLayer collection is sent to Google Tag Manager.
The gtag() function is a convenience for sending this data.
After the document content is loaded, it can be used to send event data to GTM.
gtag("event", "purchase", {
transaction_id: "BFH_5478",
value: 10,
tax: 0,
shipping: 0,
currency: "USD",
payment_method: "PayPal credit card",
items: [
{
item_id: "PB-DL",
item_name: "Playful Beginnings, with Overview, the Teacher's Guide",
affiliation: "Barchowsky Fluent Handwriting Website",
coupon: "",
discount: 0,
price: 10.00,
item_brand: "Barchowsky Fluent Handwriting",
item_variant: "download",
quantity: 1
},
]
});
The above has the same effect as
dataLayer.push({event: "purchase", ...});
Pointing that out because on the website, there can be calls to gtag(), while in a tutorial video I was watching the code displayed was dataLayer.push()