Skip to content

Instantly share code, notes, and snippets.

View marcusRB's full-sized avatar
🎯
Focusing

Marco marcusRB

🎯
Focusing
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@marcusRB
marcusRB / FBads4GTM_purchase_example.js
Created October 14, 2018 16:52
ProductPurchase as custom Event for Google Tag Manager
/* ProductPurchase as custom Event for Google Tag Manager - Update 10.2018 MR//PD
Trigger: tag fire when customEvent 'transaction' or similar purchase event, populate dataLayer at the end of transaction (after payment gateway or on thank you page)
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
<!--Product Purchase from Hybris only - Update 09.2018 MR//PD -->
<script>
fbq('track', 'Purchase', {
@marcusRB
marcusRB / FBads4GTM_addPaymentInfo_example.js
Created October 14, 2018 16:47
AddPaymentInfo event as ViewContent for Google Tag Manager
/* AddPaymentInfo event as ViewContent for Google Tag Manager - Update 10.2018 MR//PD
Trigger: event on selected PaymentInfo
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
<script>
fbq('track', 'AddPaymentInfo'); //content_category, content_ids, contents, currency, value are optionals
</script>
@marcusRB
marcusRB / FBads4GTM_InitiateViewContent_example.js
Created October 14, 2018 16:04
InitiateCheckout as ViewContent for Google Tag Manager
/* InitiateCheckout as ViewContent for Google Tag Manager - Update 10.2018 MR//PD
Trigger: when Step 1 loaded or Step 2 initiate, extract checkout value from dataLayer
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
<script>
fbq('track', 'InitiateCheckout', {
value: {{cJS - EEC - checkoutValue}}, //as FLOAT
currency: 'EUR',
});
@marcusRB
marcusRB / FBads4GTM_searchQuery_example.js
Created October 14, 2018 14:44
SearchQuery as ViewContent for Google Tag Manager
/* SearchQuery as ViewContent for Google Tag Manager - Update 10.2018 MR//PD
Trigger: fire tag when search query exist in the URL or searchQuery event fired
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
<script>
fbq('track', 'Search', {
search_string: '{{URL - SearchQuery}}', //search term or terms as STRING
content_ids: {{cJS - dlv - product.id}}, //show only first 10 elements in ARRAY
content_type: 'product', // choose between products or product_group
@marcusRB
marcusRB / FBads4GTM_productList_example.js
Created October 14, 2018 11:09
ProductList from Categories only for Google Tag Manager
/* ProductList from Categories only for Google Tag Manager - Update 10.2018 MR//PD
Trigger: Service webpage or Product webpage show products list as Impressions. Extract them from dataLayer
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
<script>
fbq('track', 'ViewContent', {
@marcusRB
marcusRB / FBads4GTM_addToWishList_example.js
Created October 14, 2018 11:01
WishList as ViewContent for Google Tag Manager
/* WishList as ViewContent for Google Tag Manager - Update 10.2018 MR//PD
Trigger: Service webpage or Product webpage when fire Wishlist button or custom event
Remember: Set Tag Sequencing load before main pageView FBads tag
*/
/*Update 28.09.2018 v2 MR//PD
Product addToWishList from categoryList and detailProduct -
NOTE: script use DOM scraping, please check last version of your CMS for to get the values,
instead doesn\'t work well or value returned will be null
*/
@marcusRB
marcusRB / FBads4GTM_addToCart_example.js
Created October 14, 2018 10:48
AddToCart as customEvent for Google Tag Manager
/* AddToCart as customEvent for Google Tag Manager - Update 10.2018 MR//PD
Trigger: tag works when custom event 'addToCart' from dataLayer fired
Remember: Set Tag Sequencing load before main pageView FBadsTag
*/
<script>
fbq('track', 'AddToCart', {
value: {{cJS - EEC - product.addToCart.price}}, //product detail Price as FLOAT
@marcusRB
marcusRB / EEC_categoryList for GTM
Created October 14, 2018 10:09
EEC_categoryList for GTM
/* EEC categoryList - Custom JS for GTM - update 09-2018 MR//PD
- EEC dataExtract for FBads, ADW, and 3rdParty
- This function create new array and use separator '>'
- {{dlv - pageHierarchy}} is a custom variable, or dataLayer extract categories levels as Array
*/
function() {
try{
if({{Page Path}}.indexOf('/p/') != -1){ //change /p/ with URL of your product
var category = {{dlv - pageHierarchy}}; // create a custom variable PageHierarchy with ARRAY of different categories Levels