GA4 is installed on your site, but when you open it you see user counts going up and down and none of the answers you actually need: where buyers come from, which pages drive sign-ups, and at which step people give up. The problem is rarely GA4 itself. Usually the important events are not tracked, internal visits are counted, and core settings such as data retention are still on their defaults.
This guide shows how to set GA4 up so it is genuinely useful for an online store, a service website, or a Laravel application, including code for tracking purchases.
How GA4 Thinks About Data
Universal Analytics was built around sessions and hits. GA4 treats every interaction as an event: viewing a page is page_view, scrolling is scroll, buying is purchase. Events carry parameters such as order value or product name. Events you mark as important are called key events (formerly conversions).
| Event type | How it is enabled | Examples |
|---|---|---|
| Automatic | As soon as the tag is installed | first_visit, session_start, page_view |
| Enhanced measurement | Toggled in the web data stream settings | scroll (90% depth), outbound clicks, site search, file downloads, form interactions |
| Recommended | Sent by you using Google's standard names | sign_up, generate_lead, add_to_cart, begin_checkout, purchase |
| Custom | Sent by you with your own names | click_chat, download_brochure |
Use recommended names whenever one exists. GA4's ecommerce reports only populate when event and parameter names follow Google's schema.
Write a Tracking Plan First
The costliest GA4 mistake is adding events ad hoc and discovering a year later that names are inconsistent and nothing compares. Before touching code, make a spreadsheet with columns for business goal, event name, parameters, trigger, and owner. Use lowercase with underscores consistently, because GA4 event names are case-sensitive.
Setting It Up Properly
- Create a property and a web data stream and note the Measurement ID (
G-XXXXXXX). - Install the tag once, either through Google Tag Manager or by adding gtag.js to your main layout. Never both, or every page view is counted twice.
- Verify in Realtime and DebugView by browsing your site in another tab.
- Raise data retention from 2 to 14 months under Admin, Data collection and modification, Data retention. This limits how far back Explorations can look.
- Filter internal traffic by defining your office IP addresses and activating the filter.
- Mark two to five key events that matter to the business, such as
purchaseandgenerate_lead. - Link Google Search Console so organic queries sit next to behavior data.
- Configure consent if you serve visitors in regions such as the EU or UK; Google's consent mode adjusts tag behavior based on the visitor's choice.
Tracking Purchases from a Laravel App
Send purchase on the thank-you page after payment is confirmed. In a Blade view, pass the order from the controller and print values safely with @json:
{{-- resources/views/checkout/thanks.blade.php --}}
@if ($order->isPaid() && ! $order->ga_tracked)
<script>
gtag('event', 'purchase', {
transaction_id: @json($order->code),
value: {{ (float) $order->total }},
currency: @json($order->currency),
items: @json($order->items->map(fn ($i) => [
'item_id' => $i->sku,
'item_name' => $i->name,
'price' => (float) $i->price,
'quantity' => $i->qty,
]))
});
</script>
@php($order->update(['ga_tracked' => true]))
@endif
The ga_tracked flag stops a refresh from sending the same purchase twice. GA4 also deduplicates on transaction_id, but guarding it in your app is safer. If payments are confirmed by a webhook rather than a redirect, use the Measurement Protocol to send the event server-side so it does not depend on the buyer reaching the thank-you page.
For a chat or call button, a custom event on click is enough:
<a href="tel:+15555550123"
onclick="gtag('event', 'click_call', { placement: 'product_page' })">
Call us
</a>
To use a parameter like placement in reports, register it as a custom dimension under Admin, Custom definitions.
Reports Worth Reading Every Week
Traffic acquisition
Shows where sessions come from by default channel group (Organic Search, Direct, Paid Social, Referral) alongside key events per channel. Small channels with high conversion rates often deserve more attention.
Pages and screens
Lists the most viewed pages and their engagement time. A product page with plenty of views and almost no add_to_cart events needs work: photos, price clarity, or shipping information.
Funnel exploration
Build steps such as view item, add to cart, begin checkout, purchase. The chart shows where people drop. For example, a big drop between checkout and purchase often points to limited payment options or surprise fees.
Path exploration
Shows the routes visitors take before converting, such as whether they read a blog guide first.
Common Setup Mistakes
- Double tagging through GTM and hard-coded gtag. Symptom: inflated page views per session.
- Purchase events without currency. Revenue will not be recorded.
- Payment provider self-referrals. Buyers returning from Stripe or PayPal show as new referral sessions; list those domains under unwanted referrals.
- Too many key events. Marking scrolls as key events makes conversion rates meaningless.
- No change log. Keep a short note whenever tags or events change so later spikes can be explained.
GA4 Checklist for a Business Site
- One tag only, verified in Realtime and DebugView.
- Data retention set to 14 months.
- Internal traffic filter active.
- Enhanced measurement reviewed toggle by toggle.
purchaseorgenerate_leadsent with value and currency.- Two to five key events tied to business goals.
- Search Console linked and consent configured where required.
- A saved funnel exploration for your purchase or sign-up flow.
From Data to Decisions
Block 30 minutes a week and answer three questions: which channel produces the most key events, which pages get views but little action, and where the largest funnel drop sits. Pick one fix, ship it, and measure again next week. A small habit like this beats an elaborate dashboard nobody opens.
GA4 shows website behavior, while real sales numbers live in your POS or order system; the benefits of business applications for small businesses explains how those pieces fit together, and this payment gateway integration walkthrough shows where a server-side purchase event would hook into a webhook. If your store is built on a Laravel source code package, for instance one from GudangCode, the event pattern above drops straight into the existing checkout views.