Created
March 17, 2019 21:14
-
-
Save RobertMatkulcik/ed96a128d7b58d859281a74508765b5f to your computer and use it in GitHub Desktop.
https://www.dream-factory.sk/
GTM example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DREAM-FACTORY.sk | |
// thx page URL | |
// https://www.dream-factory.sk/nakupny-kosik/&objednane | |
// THX page data | |
// Ecomm_totalvalue | |
// Na stránke detailu produktu prepisovať cenu produktu | |
// Na stránke košíku (v celom nákupnom procese) a na stránke dokončenej objednávky je potrebné | |
// prepisovať celkovú hodnotu produktov v košíku. | |
// Zapísať do DATA LAYER | |
// Pagetype | |
// Homepage = home | |
// Kategória = category | |
// Produkt = product | |
// Košík = cart | |
// Thank You Page (dokončená objednávka) = purchase | |
// Všetky ostatné stránky = other | |
//Check if dataLayer exists or build dataLayer | |
dataLayer = (typeof dataLayer !== 'undefined') ? dataLayer : []; | |
var pageType = null; | |
// return segment1/segment2/segment3/segment4 | |
segment_str = window.location.pathname; | |
var segment_array = segment_str.split('/'); | |
var segment1 = segment_array[1] ? segment_array[1] : null; | |
var segment2 = segment_array[2] ? segment_array[2] : null; | |
var segment3 = segment_array[3] ? segment_array[3] : null; | |
var segment4 = segment_array[4] ? segment_array[4] : null; | |
if (segment1 === null) { | |
pageType = "home"; | |
} | |
else if (segment1 === "uvod") { | |
pageType = "home"; | |
} | |
else if (segment1 === "kategoria") { | |
// check if its product detail | |
idToControll = document.getElementById("variant_price"); | |
if (document.body.contains(idToControll)) { | |
pageType = "product"; | |
} | |
else { | |
pageType = "category"; | |
} | |
} | |
else if (segment1 === "nakupny-kosik") { | |
if (segment1 === "nakupny-kosik" && segment2 === "&objednane") { | |
pageType = "purchase"; | |
} else { | |
pageType = "cart"; | |
} | |
} | |
else { | |
pageType = "other"; | |
} | |
dataLayer.push({ | |
"pageType": pageType, | |
}); | |
// PUSH example | |
// gtm_products.push({ | |
// 'name': 'Test Product', // Productname/title (Short description) - Required - for example. Brown T-shirt | |
// 'sku': 'SKU0001', // Unique product code/SKU - Vereist - for example AI1317001 | CC AJORDSTR (Artikle code + additional style coding) | |
// 'category': 'Test categorie', // Product category | |
// 'price': 9.99, // Product price (for one product) including VAT - As decimal seperator a . (dot) should be used - Required | |
// 'quantity': 1 // Number of items for this specific product - Required | |
// }); | |
/* | |
Data co som nasiel na THX page | |
type = "text/javascript" > | |
var google_conversion_id = 1048900986; | |
var google_conversion_language = "en"; | |
var google_conversion_format = "2"; | |
var google_conversion_color = "ffffff"; | |
var google_conversion_label = "ILVmCPz19QMQ-uqT9AM"; | |
var google_conversion_value = 1.00; | |
var google_conversion_currency = "EUR"; | |
var google_remarketing_only = false; | |
try { | |
var pageTracker = _gat._getTracker("UA-26922156-1"); | |
pageTracker._initData(); | |
pageTracker._trackPageview(); | |
pageTracker._addTrans( | |
"54539", | |
"dream-factory.sk", | |
"5.5", | |
"0.92", | |
"0", | |
"TST IGNORE GTM TEST", | |
"TST IGNORE GTM TEST", | |
"TST IGNORE GTM TEST" | |
); | |
pageTracker._addItem( | |
"54539", | |
"04000708D", | |
"VOLLARE - Sérum na rast rias a obočia 9ml", | |
"SÉRA NA RAST MIHALNÍC", | |
"5.5", | |
"1" | |
); | |
pageTracker._trackTrans(); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment