Follow one event through the server
Take a quote form. When the site confirms that it saved the enquiry, the web Google tag sends a generate_lead event to your tagging endpoint. A Google Analytics: GA4 client in the server container recognises the incoming request and turns it into event data. Server tags then decide whether to send the event to GA4, Google Ads or another destination. Keep the lead itself in your CRM. The analytics event only needs to describe what happened.
The web and server containers have different jobs. The web container still listens for browser interactions and takes the visitor's consent choices from your consent platform. The server container receives HTTP requests, applies its triggers and transformations and calls the approved destinations. A booking system can also send an event directly from its back end when it owns the outcome. Decide which system confirms each event before wiring it up.
A first-party endpoint sits within your site's domain, for example metrics.example.com for www.example.com. That subdomain is a separate origin. Google recommends same-origin serving where practical, such as www.example.com/metrics, using infrastructure that routes the path to the tagging service. The cloud provider's default URL is useful for initial tests. Decide how to serve the endpoint before you rely on server-set cookies in production.
Decide what you expect to improve
| Objective | Where the change helps | What to verify |
|---|---|---|
| Control outbound data | Server transformations can limit the event parameters visible to each tag | Compare the incoming event with what each destination actually receives. |
| Page speed | Moving eligible vendor tags off the page can reduce browser requests and script work | Measure comparable pages on mobile before and after retiring the scripts. |
| Cookie durability | A first-party endpoint supports server-set cookies for permitted measurement | Check cookie attributes and storage behaviour in the browsers your visitors use. |
Start with a genuine problem. If a product URL includes information that should never reach an ad platform, change the site so it stops putting that information in the URL. Use a per-destination allowlist as an additional safeguard. Inspect page URLs and referrers along with the fields you deliberately add. Automatic fields can carry information to a vendor too.
Performance depends on which scripts you can retire. A live chat widget still needs to run on the page. If you keep every original measurement script and add a new collection route, compare the resulting workload before declaring a gain. Cookie behaviour likewise depends on the browser, the domain setup and the user's choices. Treat greater durability as a possible effect under supported conditions, with no fixed lifetime.
A visitor's refusal still applies after a routing change. Respect browser and extension controls. If the site never observes an interaction, routing its events through a server cannot recover it.
Deploy the tagging endpoint
- In Google Tag Manager, create a container and choose Server. Use automatic provisioning on Cloud Run if the supplied project and billing arrangement fit, or follow Google's manual deployment guide if your team manages the infrastructure. Allocate an owner for Cloud billing and production access.
- Map your measurement subdomain or first-party path. Set the DNS or proxy route required by your chosen Cloud Run setup and verify HTTPS. In the server container, open Admin, then Container Settings, and add the public endpoint under Add URL.
- In the web Google tag that sends your GA4 traffic, set server_container_url to the endpoint. In the server container, make sure the Google Analytics: GA4 client can claim the request. Use Preview to follow a single page view from the browser to the incoming request.
- Add a Google Analytics: GA4 tag in the server container and scope it to the expected client and events. Check the property and any explicit measurement ID. Open the outgoing request in Preview, then check DebugView with a debug-enabled event.
Test a form that succeeds, a form rejected by the site and a refreshed confirmation screen. You should be able to explain the count in each case from the application's records. A working endpoint proves it can receive requests. Keep the event-level tests as your release criteria.
Connect Google Ads and Meta independently
For a direct Google Ads website conversion, set up Conversion Linker in the server container as described in Google's server-side guide. Create a Google Ads Conversion Tracking tag with the conversion ID and label from the correct action. Trigger it only on the confirmed business event. For purchases, verify value, currency and transaction ID against the order. Keep GA4 key events and Google Ads goals in view when moving tags, especially if an Analytics import already represents the same outcome.
For Meta, use a maintained integration or a vetted server template to send authorised events to the Conversions API. Verify the destination in Events Manager and keep access tokens in server-side secret storage. For a website event, send event_name, event_time, action_source set to website and event_source_url. Include user_data with the original browser’s client_user_agent and other permitted matching fields. Follow Meta’s field-specific rules, including hashing email and phone if sent and leaving client_user_agent unhashed.
If Meta Pixel and the Conversions API both report the same event, create its ID once and use that value for Pixel eventID and API event_id with the same event name. In Test Events, inspect both arrivals and verify deduplication. For Google Ads, remove the equivalent web conversion tag once the server route is verified and check that the same business event is represented only once in bidding. Record the versions of both containers so a rollback restores a coherent routing setup.
Carry consent through the entire route
Keep the consent banner or consent management platform on the site. Configure the default state before Google tags run and update it when the visitor makes a choice. The web tag conveys consent information with requests to the GA4 client in the server container. Check analytics_storage, ad_storage, ad_user_data and ad_personalization as applicable. Google's consent mode adjusts supported Google tags. Apply separate, explicit consent rules to Meta and other integrations.
If your approved approach blocks tracking before consent, verify the browser sends no such request, including through reloads. Advanced consent mode can send cookieless signals under denied states. Have the privacy owner approve the chosen behaviour and test it. Include a visit with no choice yet, a refusal, a limited acceptance and a withdrawal. Inspect incoming and outgoing requests and browser storage. Apply equivalent checks to any CRM or back-end feed that can send events without a live browser.
Under the GDPR, where applicable, document the purposes, legal bases, retention periods and recipients. Check the relevant rules on terminal storage, any processor contracts and international transfers. Decide what the endpoint is allowed to receive and avoid collecting unnecessary fields upstream. Review logs as a separate copy of the data. Restrict access and avoid retaining request bodies or sensitive URL parameters. Basic error monitoring can usually work from status codes, event types and timing.
Run a pilot or keep your existing setup
Budget for the tagging service, any proxy or load balancer, network traffic and logging. Volume depends on the requests you send, including page views and repeat attempts, as well as on the conversions you record. Capacity and availability requirements may mean keeping instances running. Assign ownership for DNS and certificates, tag updates, checking bills and investigating failed deliveries. Agree what to do if the endpoint is unavailable during a campaign.
A small business with one form and reliable Google Ads tracking can often keep its browser setup. Fix a misfiring form trigger or an unrecorded CRM outcome at the source. For paid leads that become customers later, a CRM import can address that measurement gap directly. Server-side tagging has a clearer role if multiple destinations need different data, an existing back end can confirm events or third-party scripts create a measured performance problem.
Pilot one event and one destination. Ask the developer to show the event reaching the server, the fields sent to the vendor and what changes when consent is denied. After release, reconcile eligible events against the system that records them. Investigate unexpected gaps and duplicates before expanding to additional events. Define who can pause forwarding if an integration starts sending the wrong data or the cost of operating it changes.
Frequently asked questions
- Does server-side tracking replace the web container?
- No. The browser still has to observe interactions such as a form submission. The server container can take over delivery to supported destinations.
- Do first-party cookies remove the need for consent?
- No. Where storage or measurement requires consent, it still applies to a cookie set through your first-party endpoint.
- Does server-side tagging get around an ad blocker?
- No. A server endpoint is a delivery route for permitted events. If a browser or extension prevents collection, respect that choice and expect some events to remain unobserved.
- Can I start with GA4 and add ad platforms later?
- Yes. Prove the GA4 route and consent behaviour first. Add Google Ads or Meta only when the event mapping and deduplication checks are ready.
Sources
- Google for Developers — Introduction to server-side tagging
- Google for Developers — Set up server-side tagging with Cloud Run
- Google for Developers — Custom domain configuration
- Google for Developers — Send data to server-side Tag Manager
- Google for Developers — Transformations
- Google for Developers — Preview and debug server containers
- Google for Developers — Google Ads conversions in server-side Tag Manager
- Google for Developers — Consent Mode with server-side Tag Manager
- Google for Developers — Consent Mode
- Meta for Developers — Conversions API parameters
- Meta for Developers — Deduplicate Pixel and server events
- Meta for Developers — Conversions API and Test Events
- EUR-Lex — ePrivacy Directive, Article 5(3)
- EUR-Lex — General Data Protection Regulation
- Meta for Developers — required server event fields