Simply connecting Google Analytics to an online store is not enough if you want to understand not only how many people visit the website, but also what they do with the products.
Which products do they view? What do they add to the cart? What do they save to their wishlist? At what stage do they leave the website? This is what e-commerce events in GA4 are used for.
In this article, I'll use a simple example to show what these events can look like in a Laravel online store. This is not a complete analytics implementation — we'll focus on the basic idea and the data being passed.
What are e-commerce events?
A regular page view tells us very little about customer behavior. For an online store, specific actions are much more useful:
- viewed a product list;
- opened a product page;
- added a product to the wishlist;
- added a product to the cart;
- removed a product from the cart;
- started checkout;
- completed an order.
GA4 provides standard e-commerce events for these actions. In a Laravel store, event data can be prepared by the application and passed through dataLayer, after which Google Tag Manager sends it to GA4.
Viewing a product list
For example, a user opens a product category. At this point, we can send the view_item_list event.
{
"event": "view_item_list",
"ecommerce": {
"items": [
{
"item_id": "PHONE-001",
"item_name": "Smartphone Nova X1 128GB",
"price": 24999,
"item_category": "smartphones"
},
{
"item_id": "PHONE-002",
"item_name": "Smartphone Nova X2 256GB",
"price": 32999,
"item_category": "smartphones"
}
]
}
}
In a real catalog, the items array is generated dynamically. GA4 receives more than just information that a page was opened — it can understand which products were actually shown to the user.
Viewing a specific product
When a user opens a product page, the view_item event is sent.
{
"event": "view_item",
"ecommerce": {
"items": [
{
"item_id": "PHONE-002",
"item_name": "Smartphone Nova X2 256GB",
"currency": "UAH",
"price": 32999,
"item_category": "smartphones"
}
]
}
}
Now analytics can distinguish between a product simply appearing in a catalog and a user actually opening its page. For example, you can identify products that are shown frequently but rarely opened.
Adding a product to the cart
The next important step is add_to_cart. Here, the quantity is added to the product data.
{
"event": "add_to_cart",
"ecommerce": {
"items": [
{
"item_id": "PHONE-002",
"item_name": "Smartphone Nova X2 256GB",
"currency": "UAH",
"price": 32999,
"quantity": 1,
"item_category": "smartphones"
}
]
}
}
The event should be sent at the moment the product is actually added to the cart. In a modern online store, this often happens without a page reload, so tracking analytics only by URL is no longer enough.
Wishlist actions can be tracked too
If the store has a wishlist, you can send add_to_wishlist when a user saves a product. The structure is similar: product ID, name, price, currency, and category.
At first glance, this may not seem as important as adding a product to the cart, but it helps identify products that attract interest even when the user is not ready to buy yet.
Why pass item_id?
A product name can change over time, so it is better to have a stable identifier for analytics. I try to use the same item_id for a product across all e-commerce events.
This keeps product views, cart additions, and other actions associated with the same product even if its name changes.
What about checkout and completed orders?
Store analytics does not end here. Starting checkout and completing an order are tracked separately. This is where more interesting details appear: order value, products, quantities, discounts, transaction identification, and protection against counting the same purchase more than once.
For example, simply refreshing the page after a successful order should not create another conversion in analytics. I intentionally leave this part of the implementation outside this article, as it already depends on the architecture of a particular store and its checkout process.
Not only GA4
A well-designed event structure can become the foundation for more than just Google Analytics. The same user actions can also be used by advertising and other marketing tools.
What do we get in the end?
After setting up e-commerce analytics, we see much more than the number of visitors. We can analyze the user's path: catalog → product → wishlist or cart → checkout → order.
If a product is shown frequently but rarely opened, the problem may be its image, name, or price. If people view it but do not add it to the cart, that is a different signal. And if users reach the cart but do not complete checkout, it is worth looking at the checkout process itself.
Need help setting up e-commerce analytics?
I develop and support web projects built with Laravel and other platforms, including GA4, Google Tag Manager, and e-commerce event tracking. I can set up analytics for an existing online store or implement it as part of a new project.

Comments (0)
No comments yet. Be the first!