E-Commerce and Shopping Cart Tracking
To set up a comprehensive E-Commerce tracking in Atrilyx, you need to integrate different categories of actions. Here's a simplified explanation and code examples for each category, using pet food as the product.
The code examples use data layer pushes which your tag manager can pickup from and pass the values to your Atrilyx tracking tags.
Product Views (Optional): You can track how many people have viewed a page where your pet food is available for sale. This helps calculate the product conversion rate.
Example Product View Snippet:
CODE// Push Product View Data to dataLayer dataLayer.push({ ecommerce: { detail: { products: [{ id: 'PF123', // Required - unique product identifier name: 'Premium Dog Food', // Optional - product name category: 'Pet Supplies', // Optional - category name or array of up to 5 categories price: 24.99 // Optional - price }] } } }); // Track the product view as a page view dataLayer.push({ event: 'gtm.js' });
Cart Updates (Optional): You can track cart additions and removals to gather information about abandoned carts.
Example Product Cart Update:
CODE// Add an item to the cart dataLayer.push({ ecommerce: { add: { products: [{ id: 'PF123', // Required - unique product identifier name: 'Premium Dog Food', // Optional - product name category: 'Pet Supplies', // Optional - category name or array of up to 5 categories price: 24.99, // Recommended - price quantity: 2 // Optional - quantity (defaults to 1) }] } } }); // Track the cart update with the total value dataLayer.push({ event: 'addToCart', ecommerce: { currencyCode: 'USD', value: 49.98 // Total cart value } });
Order Updates (Required): Tracking orders is essential for successful Ecommerce tracking.
Example of Adding a Product to the Order & Tracking the Ecommerce Order:
CODE// Add a product to the order dataLayer.push({ ecommerce: { purchase: { actionField: { id: 'ORD123', // Required - unique order ID revenue: 49.98, // Required - total revenue tax: 5.20, // Optional - tax amount shipping: 6.99 // Optional - shipping amount }, products: [{ id: 'PF123', // Required - unique product identifier name: 'Premium Dog Food', // Optional - product name category: 'Pet Supplies', // Optional - category name or array of up to 5 categories price: 24.99, // Recommended - product price quantity: 2 // Optional - quantity (defaults to 1) }] } } });
Note: Make sure to pass currency values as integers or floats, not as strings. Use the appropriate data types when implementing the code examples for accurate tracking.