Module to enhanced tracking for Google Analytics 4 (via Google Tag Manager).
Google Tag Manager settings provided in module, include example implementations for Google Analytics 4 and Facebook Pixel.
Web
Measurement ID
Create and get ID of Facebook Pixel: here
container.json
file (help is available here).(Settings) Google Analytics
to Measurement ID
(Settings) Facebook Pixel
to ID of Facebook Pixelhttp://yoursite.com/module/tracksmart/ajax
{
"item_name": "Item name",
"item_id": 12345,
"price": 12.34,
"item_brand": "Brand",
"item_category": "Category",
"item_variant": "Variant",
"quantity": 1
}
Bad Request
In header
, module create instance of TrackSmart
as variable trackSmart
.
let trackSmart = new TrackSmart('CONTAINER_ID', 'USER_ID'); // 'USER_ID' is optional
trackSmart.build(); // Initialize connection
trackSmart.process('event_name', {
ecommerce: 'event_body'
}); // Send request to Google Tag Manager
trackSmart.destroy(); // Destroy session