Ready-made integrations Google Ads

Google Ads

Markdown
Loading…

Load Google Ads conversion tracking with one integration and let the SDK keep its Consent Mode signals up to date.

googleAds() loads Google Ads conversion tracking and registers your conversion id. Consent reaches Google through Google Consent Mode: the SDK tells Google what the visitor allowed, on page load and on every change.

Set it up

First add the Consent Mode default, once, before any Google tag: Google Consent Mode v2 → Add the default.

Then install the integrations package and add googleAds() to the initCookieYes() call you already have:

npm install @cookieyes/scripts
src/consent-manager.tsx
import { initCookieYes } from "@cookieyes/react";
import { googleAds } from "@cookieyes/scripts";

initCookieYes({
  mode: "cookie-only",
  regulation: "GDPR",
  integrations: [googleAds({ conversionId: "AW-XXXXXXXXX" })],
});

Report conversions with gtag("event", "conversion", …) as usual. It is always safe to call: the Consent Mode default you added defines gtag and the dataLayer before anything else runs. Running ga4() as well is fine: both share one Google library.

Options

OptionDefaultWhat it does
conversionIdrequiredYour Google Ads id, "AW-…"
category"advertisement"The category the visitor must grant
consentMode"advanced""advanced" loads the tag at once and lets Consent Mode gate it. "basic" loads it only after consent and removes it, with the _gcl_au cookie, on withdrawal. See Google Consent Mode v2 → Load the tag before or after consent
paramsnoneExtra gtag("config", …) settings for the Ads tag
restrictedDataProcessingautomaticGoogle's US privacy flag. Left unset, it turns on for every visitor covered by CCPA. true or false forces it
id"google-ads"Only needed when you run more than one Ads account

Common mistakes

Every conversion is counted twice. Google Ads is also loaded by your Google Tag Manager container. Use googleTagManager() or googleAds() for an account, not both. The SDK logs a warning when it sees both.

A returning visitor is treated as denied, although they accepted last time. The Consent Mode default is missing, so the update sent on page load was skipped and the Ads tag stays denied until the visitor changes their choice. Add the default as shown on Google Consent Mode v2 → Add the default.

Next steps

On this page