Module to enhanced tracking for Google Analytics 4 (via Google Tag Manager).
- Very light (no unnecessary libraries)
- Efficient (no database queries)
- Scrupulous (sends necessary information in the correct formats)
- Flexible (e.g.: implementations for Facebook Pixel, simple API in JavaScript, and more)
- Open source
- Categories page view
- Products page view
- Products added to cart
- Products removed from cart
- Checkout
- Purchase
Google Tag Manager settings provided in module, include example implementations for Google Analytics 4 and Facebook Pixel.
- PrestaShop 1.7+
- PHP 7+
- Download files from releases
- Install in PrestaShop
- Provide Container ID from GTM, mark as ready and save :)
- Create new property (select target country and currency)
- Set up new data stream:
Web
- Provide details
- Save
Measurement ID
Create and get ID of Facebook Pixel: here
- Set up settings from
container.json
file (help is available here). - Replace values in variables:
(Settings) Google Analytics
toMeasurement ID
(Settings) Facebook Pixel
to ID of Facebook Pixel
- Push tags. Done :)
- Request URL:
http://yoursite.com/module/tracksmart/ajax
- Request body:
- Response:
{
"item_name": "Item name",
"item_id": 12345,
"price": 12.34,
"item_brand": "Brand",
"item_category": "Category",
"item_variant": "Variant",
"quantity": 1
}
- Exceptions:
- 400:
Bad Request
- 400:
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