Google Analytics 4 integration for QR codes and links

Send every QR code scan, link click, form submission and piece of visitor data captured to Google Analytics 4, server side through the Measurement Protocol. No delay for visitors, no personal data, only people's visits, and form answers such as a rating score as event parameters. Setup, events, custom dimensions, and how it compares with the Google tag pixel.

Integrations
11 min read
By Laurent Schaffner
Updated November 4, 2026
Try it yourself

Connect Google Analytics 4 with the Assistant.

Connect Google Analytics with my Measurement ID G-ABC123DEF4 and my Measurement Protocol API secret, then send a test event

Try this prompt

Short answer

Open Integrations in the Linkbreakers dashboard, pick Google Analytics 4, paste your GA4 Measurement ID (G-...) and a Measurement Protocol API secret, and select Connect. From then on, every person who scans one of your QR codes or opens one of your links shows up in GA4 as a qr_scan or link_click event, and each form they submit as a generate_lead event, with the link, the city, the country and the device.

Linkbreakers sends the events from its servers, after the redirect, so visitors wait for nothing and ad blockers cannot stop them. Personal data never leaves: emails, names, phone numbers and addresses stay in Linkbreakers. Other answers, such as a rating score, go with the events while Send visitor data with events is on. It is available on every plan, Free included.

Quick summary

  • Connect once per workspace with a Measurement ID and a Measurement Protocol API secret
  • Every link and QR code of the workspace is covered
  • Sent server side through Google's Measurement Protocol: no script, no delay, no ad blocker in the way
  • Events: qr_scan, link_click, generate_lead, location_shared, visitor_data_added
  • Each event carries the link, the short link, a session, the city, the country and the device
  • No personal data: no emails, names, phone numbers, addresses or coordinates
  • Other answers and visitor attributes, such as a rating, as lb_ parameters while Send visitor data with events is on
  • Only people's visits: bots, link previews, AI agents and automated browsers are left out
  • Also available from the Assistant, the MCP server, the REST API, the CLI and the SDKs

How it works

A Google tag runs in the visitor's browser. This integration does not: when a visit happens, Linkbreakers redirects the visitor as usual, then its servers send the event to Google Analytics through the Measurement Protocol, Google's API for sending events from a server.

Each step of the visit becomes its own event when it happens. A visitor who scans a poster, fills in a form and shares their location produces a qr_scan, then a generate_lead, then a location_shared, all tied to the same GA4 session.

In GA4:

  • The user is the Linkbreakers device (the GA4 client ID) and, when known, the Linkbreakers visitor ID (the GA4 user ID). A visitor who scans twice is one user with two sessions
  • The session is the visit, so every step of one visit lands in one session
  • Location and device use GA4's own fields, so the standard Country, City, Device category, Operating system and Browser dimensions work in your reports without any setup

Events sent

Event When Parameters
qr_scan A person scans a QR code visit_type (first or returning)
link_click A person opens a link (not from a QR code) visit_type (first or returning)
generate_lead A person submits a form step form_title, fields (field names, such as email,company), fields_count
location_shared A person shares their location on a Location request step none beyond the common ones
visitor_data_added Any other step saves data to the visitor's profile fields (attribute names), source (the step kind)

Every event also carries link_id, link_name, short_link, session_id and engagement_time_msec. When a step also saves attributes to the visitor's profile, their names come in saved_attributes.

generate_lead is one of GA4's recommended events, so GA4 already knows what it means and you can mark it as a key event in one click.

Visitor data as event parameters

When Send visitor data with events is on (the default), each event also carries the data the visitor gave at that step, as parameters named lb_ and the attribute key: a form's answers on generate_lead, and the custom attributes a step saved to the visitor's profile. A rating field named rating arrives as lb_rating with its score as a number, so you can register it under Admin > Custom definitions as a custom metric and average it in GA4; choices arrive as text, up to 100 characters. Text and paragraph answers can hold a name or an address, so they are sent only for the keys you list under Only these attribute keys. Keys are written in lower case with underscores (Plan Tier becomes lb_plan_tier) and cut to 40 characters. GA4 takes 25 parameters per event, so the event's own parameters come first and visitor data fills the rest.

Personal data is never sent, whatever the setting: emails, phone numbers, first and last names, addresses and postcodes, dates of birth and coordinates are left out, by field type and by key, and so is any answer that looks like an email address or a phone number. To send only some attributes, list their keys under Only these attribute keys; to send none, turn the switch off. From an agent or a script, set visitorAttributesEnabled and visitorAttributeKeys ({"keys": ["rating"]}) on PUT /v1/integrations/google-analytics or google_analytics_integration_update.

What is never sent

Google's terms forbid sending personal data to Google Analytics, and a property that receives it can be closed. Linkbreakers never sends:

  • Emails, names, phone numbers, addresses, postcodes, dates of birth or ID numbers, by field type and by key
  • Any answer that looks like an email address or a phone number
  • Text and paragraph answers, unless their key is listed under Only these attribute keys
  • Any answer or attribute value at all while Send visitor data with events is off
  • GPS coordinates from a Location request step
  • IP addresses

GA4 gets the names of the fields, such as email,company, so you know a lead gave their email without GA4 ever knowing which one. The leads themselves stay in Linkbreakers, where you can see who scanned or send them on with webhooks, HubSpot or Slack.

Who is sent

Only visits classified as Human. Crawlers, link previews (Slack, Teams, Discord, WhatsApp, Facebook, LinkedIn), AI agents and recognized automated browsers are never sent, so they do not inflate your GA4 numbers. See how Linkbreakers detects AI agents and automated browsers.

Visits past your plan's tracked visits allowance are recorded but locked, and locked visits reach no integration, Google Analytics included.

Step-by-step setup

1. Find your Measurement ID

In Google Analytics, open Admin > Data streams, select your web stream and copy the Measurement ID. It starts with G-.

2. Create a Measurement Protocol API secret

On the same web stream page, open Measurement Protocol API secrets, select Create, give it a name such as "Linkbreakers" and copy the secret value. GA4 may ask you to accept its data collection terms first.

3. Connect it in Linkbreakers

  1. Open the dashboard and go to Integrations
  2. Open Google Analytics 4
  3. Paste the Measurement ID and the API secret
  4. Select Connect

The secret is stored encrypted and never shown again. To change property later, paste a new Measurement ID; leave the secret empty to keep the stored one.

4. Send a test event

Select Send test event. Linkbreakers sends a linkbreakers_test event in debug mode. In GA4, open Admin > DebugView: it shows up within a minute.

Check DebugView rather than trusting the button alone. Google accepts Measurement Protocol events even with a wrong API secret and silently drops them, so the test can only prove the secret is right if the event appears there.

5. Register the custom dimensions

GA4 shows its own fields (country, city, device) everywhere, but custom parameters such as link_name only appear in standard reports once registered. In GA4, open Admin > Custom definitions > Create custom dimension, choose the Event scope and add the ones you need:

Dimension name Event parameter
Link name link_name
Short link short_link
Visit type visit_type
Form title form_title
Fields captured fields
Rating (custom metric) lb_rating

Dimensions only apply to events received after you create them. Explorations can use the parameters right away.

6. Mark leads as a key event

In GA4, open Admin > Events, find generate_lead once one has arrived, and turn on Mark as key event. Form submissions from your QR codes then count as conversions in your reports and can be imported into Google Ads.

GA4 integration or Google tag pixel?

Linkbreakers has two ways to reach GA4. They do different jobs:

Google Analytics 4 integration Google tag pixel
Where it runs Linkbreakers' servers The visitor's browser
Delay for the visitor None A short page, usually well under a second, at most 2 seconds
Blocked by ad blockers No Yes
What GA4 receives Scans, clicks, leads, shared locations, captured data, with link, country, city and device A page_view with the link address
Builds Google Ads remarketing audiences No Yes, with an AW- tag or a GA4 audience
Cookies on the visitor's browser None Google's analytics and advertising cookies

Use the integration for reporting: how many people scanned which QR code, from where, and how many became leads. Use the Google tag pixel when you want to retarget scanners with Google Ads.

You can use both. If both point at the same GA4 property, each visit is counted twice, once as a page_view and once as a qr_scan or link_click. Keep the pixel for Google Ads (AW-) and the integration for GA4, or send them to different GA4 properties.

Set it up from an AI agent, the API or the CLI

Assistant: in the dashboard, ask "Connect Google Analytics with G-ABC123DEF4 and my API secret, then send a test event".

MCP server: an agent connected to the Linkbreakers MCP server has google_analytics_integration_get, google_analytics_integration_update, google_analytics_integration_test and google_analytics_integration_delete. For example:

Connect my Linkbreakers workspace to Google Analytics with Measurement ID G-ABC123DEF4 and API secret abcDEF123, send a test event, and tell me what to check in DebugView.

REST API, with a token that has the integrations:write scope:

Bash
curl -X PUT https://api.linkbreakers.com/v1/integrations/google-analytics \
  -H "Authorization: Bearer $LINKBREAKERS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"measurementId": "G-ABC123DEF4", "apiSecret": "abcDEF123"}'

curl -X POST https://api.linkbreakers.com/v1/integrations/google-analytics/test \
  -H "Authorization: Bearer $LINKBREAKERS_TOKEN" \
  -H "Content-Type: application/json" -d '{}'

GET /v1/integrations/google-analytics returns the Measurement ID, whether a secret is set, when an event was last sent and the last error, never the secret. DELETE disconnects it.

CLI, from the next CLI release:

Bash
linkbreakers google-analytics-integrations update --measurement-id G-ABC123DEF4 --api-secret abcDEF123
linkbreakers google-analytics-integrations test

The same operations are in the TypeScript, Python, Go, Java and Rust SDKs. See set up every Linkbreakers integration with an AI agent for the other integrations an agent can configure.

Limits and caveats

  • Scanners are their own GA4 users. The scan is not joined with the same person's later visit to your website, which GA4 sees through its own cookie. Add UTM parameters to your destinations to attribute that website visit to the campaign
  • No personal data, by design. Answers that are not personal, such as a rating, are sent only while Send visitor data with events is on
  • Custom dimensions need registering in GA4 before they show in standard reports, and only apply from then on
  • Wrong secrets fail silently on Google's side; check DebugView after connecting
  • One property per workspace. Use a workspace per client to send each client's scans to their own property
  • Workspace-wide. Every link and QR code of the workspace is sent; filter on link_name or short_link in GA4
  • Late events. GA4 accepts events up to 72 hours old; a step sent later than that is dated when it is sent

Frequently asked questions

No. The events are sent from Linkbreakers' servers after the visitor has been redirected.

Is it included on the Free plan?

Yes. The Google Analytics 4 integration is available on every plan.

Will form answers end up in Google Analytics?

Personal data never does: emails, names, phone numbers and addresses stay in Linkbreakers, as Google's terms require. Other answers, such as a rating or a choice, are sent as lb_ parameters while Send visitor data with events is on, and text answers only for the keys you list. Turn the switch off to send field names only.

Can I see my rating scores in Google Analytics?

Yes. With Send visitor data with events on, a rating field arrives on generate_lead as a number, named lb_ and the field key, such as lb_rating. Register it as a custom metric in GA4 to average it by link, country or device.

Why don't I see my test event?

Look in Admin > DebugView, not in the standard reports, which take up to a day. If it is not there after a minute, the API secret or the Measurement ID is wrong: Google accepts the request either way. Create a new secret on the right web stream and connect again.

The integration sets no cookie and runs no script in the visitor's browser, so there is nothing for a cookie banner to block on the link itself. Sending visit data to Google is still processing on your behalf, so cover Google Analytics in your privacy policy and check what your jurisdiction requires.

Can I keep using the Google tag pixel?

Yes. Point it at Google Ads, or at a different GA4 property, so visits are not counted twice in the same one.

Sources

Last reviewed

2026-11-01 by Laurent Schaffner.

About the Author

LS

Laurent Schaffner

Founder & Engineer at Linkbreakers

Passionate about building tools that help businesses track and optimize their digital marketing efforts. Laurent founded Linkbreakers to make QR code analytics accessible and actionable for companies of all sizes.