Last active
March 15, 2020 22:28
-
-
Save javimata/4a781d40d41d7eb485d00ae6f647f160 to your computer and use it in GitHub Desktop.
Configuración de eventos FB Pixel & Google Analytics
This file contains 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
/* | |
* CONFIGURACION DE ADD TO CART | |
* Debemos identificar el click en el botón | |
*/ | |
var button = document.getElementById('addToCartButton'); | |
button.addEventListener( 'click', function() { | |
fbq('track', 'AddToCart', { | |
content_name: 'Nombre del producto', | |
content_category: 'Categoria del producto', | |
content_ids: ['1'], | |
content_type: 'product', | |
value: 100.00, | |
currency: 'MXN' | |
}); | |
gtag('event','add_to_cart', { | |
'items': [ | |
{ | |
'id': '1', | |
'name': 'Nombre del producto', | |
'price': '100', | |
'currency': 'MXN', | |
'quantity': '1' | |
} | |
] | |
}); | |
// Evento opcional de respaldo | |
gtag('event', 'click', { 'event_category': 'carrito', 'event_label': 'addToCart', 'value': 100 }); | |
}, false ); | |
/* | |
* MEDICIÓN DE FORMULARIOS (InitialCheckout) | |
* Esto debe ir dentro del success del validador | |
*/ | |
fbq('track', 'InitiateCheckout', { | |
content_name: 'Nombre del producto', | |
content_category: 'Categoria del producto', | |
content_ids: ['1'], | |
content_type: 'product', | |
value: 100.00, | |
currency: 'MXN' | |
}); | |
gtag('event', 'begin_checkout', { | |
"items": [ | |
{ | |
"id": "1", | |
"name": "Nombre del producto", | |
"quantity": 1, | |
"price": '100' | |
} | |
] | |
}); | |
// Evento opcional de respaldo | |
gtag('event', 'click', { 'event_category': 'carrito', 'event_label': 'beginCheckout', 'value': 100 }); | |
/* | |
* MEDICIÓN DE FORMULARIOS (AddPaymentInfo) | |
* Esto debe ir dentro del success del validador | |
*/ | |
fbq('track', 'AddPaymentInfo', { | |
content_name: 'Nombre del producto', | |
content_category: 'Categoria del producto', | |
content_ids: ['1'], | |
content_type: 'product', | |
value: 100.00, | |
currency: 'MXN' | |
}); | |
gtag('event', 'add_payment_info', { | |
"items": [ | |
{ | |
"id": "1", | |
"name": "Nombre del producto", | |
"quantity": 1, | |
"price": '100' | |
} | |
] | |
}); | |
// Evento opcional de respaldo | |
gtag('event', 'click', { 'event_category': 'carrito', 'event_label': 'AddPaymentInfo', 'value': 100 }); | |
/* | |
* MEDICIÓN DE FORMULARIOS (Purchase) | |
* Este evento debe generarse en la página de aterrizaje despues del pago exitoso | |
*/ | |
fbq('track', 'Purchase', { | |
content_name: 'Nombre del producto', | |
content_category: 'Categoria del producto', | |
content_ids: ['1'], | |
content_type: 'product', | |
value: 100.00, | |
currency: 'MXN' | |
}); | |
gtag('event', 'purchase', { | |
"transaction_id": "24.031608523954162", | |
"affiliation": "Nombre de la tienda", | |
"value": 100, | |
"currency": "MXN", | |
"tax": 0, | |
"shipping": 0, | |
"items": [ | |
{ | |
"id": "1", | |
"name": "Nombre del producto", | |
"quantity": 1, | |
"price": '100' | |
} | |
] | |
}); | |
// Evento opcional de respaldo | |
gtag('event', 'click', { 'event_category': 'carrito', 'event_label': 'Purchase', 'value': 100 }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment