Google Analytics & Meta Pixel

Send every link click to Google Analytics 4 and Meta Pixel automatically. Configure GA4 Measurement Protocol and Meta Conversions API per custom domain in Smler


Google Analytics & Meta Pixel

Smler can forward every link click to Google Analytics 4 and Meta Pixel automatically — no JavaScript snippet or tag manager required. The integration runs server-side using the GA4 Measurement Protocol and Meta Conversions API, so it works for every click regardless of ad-blocker or browser privacy settings.

How it works

Pixel tracking is configured per custom domain. When a visitor clicks any short link under that domain, Smler fires the configured events to GA4 and Meta in the background before redirecting the visitor. The redirect itself is not delayed.

Setting up GA4 tracking

1. Create a GA4 API Secret

  1. Open Google Analytics and go to Admin → Data Streams.

  2. Select your web data stream.

  3. Under Measurement Protocol API secrets, click Create and copy the secret value.

  4. Your Measurement ID is shown at the top of the stream details page (format: G-XXXXXXXXXX).

2. Configure in Smler

Run the following GraphQL mutation authenticated with your API key:

mutation {
  upsertPixelConfig(
    domain: "links.acme.io"
    gaPropertyId: "G-XXXXXXXXXX"
    gaApiSecret: "your-api-secret"
  ) {
    id
    domain
    gaPropertyId
  }
}

From this point on, every click on a short link under links.acme.io fires a link_click event to your GA4 property.

GA4 event parameters

The link_click event is sent with the following custom parameters. You can register these as custom dimensions in GA4 to use them in reports and audiences.

Parameter

Description

short_url

The short code of the clicked link (e.g. abc123).

domain

The custom domain the link was served from.

country

ISO 3166-1 alpha-2 country code of the visitor.

city

City of the visitor.

device_category

Device type: mobile, desktop, tablet.

browser

Browser name, e.g. Chrome.

os

Operating system, e.g. Android.

referrer

Referring domain, e.g. google.com.

utm_source

UTM source from the original link.

utm_medium

UTM medium.

utm_campaign

UTM campaign.

utm_term

UTM term.

utm_content

UTM content.

Setting up Meta Pixel tracking

1. Get your Pixel ID and access token

  1. Go to Meta Events Manager.

  2. Select your pixel and copy the Pixel ID.

  3. Under Settings → Conversions API, generate a System User Access Token with ads_management and business_management permissions.

2. Configure in Smler

mutation {
  upsertPixelConfig(
    domain: "links.acme.io"
    metaPixelId: "1234567890123456"
    metaAccessToken: "EAAxxxx..."
  ) {
    id
    domain
    metaPixelId
  }
}

You can configure GA4 and Meta together in a single mutation by passing all four fields at once.

Meta event details

Smler fires a PageView event to the Meta Conversions API on each click. The payload includes:

  • client_ip_address — visitor's IP address

  • client_user_agent — visitor's user agent string

  • country — SHA-256 hashed lowercase country code (per Meta spec)

  • Custom data: short_url, domain, referrer, and UTM parameters

Viewing and removing a pixel config

Query the current configuration for a domain:

query {
  pixelConfig(domain: "links.acme.io") {
    gaPropertyId
    metaPixelId
    updatedAt
  }
}

Remove all pixel tracking for a domain:

mutation {
  deletePixelConfig(domain: "links.acme.io")
}

Privacy considerations

  • No cookies are set. All tracking is server-side only.

  • For Meta, the country field is hashed (SHA-256) before transmission. IP and user agent are sent to Meta as-is — Meta hashes these on their end for storage.

  • Smler does not store your GA4 API secret or Meta access token in logs. They are stored encrypted in your account.

  • Ensure your privacy policy discloses server-side analytics tracking to your users.

Troubleshooting

Issue

Fix

Events not appearing in GA4 DebugView

GA4 Measurement Protocol events are not shown in DebugView. Use the Realtime report and filter by event name link_click instead.

Meta events show low match quality

Match quality improves if you also fire the browser-side pixel. Server-side events from Smler complement browser events — enable deduplication using the event_id field if needed.

Mutation returns "Domain not found"

The domain must already be registered under your account in Domains. Only domains you own can have a pixel config.

Published with LeafPad