Get Google Ads tracking script

<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Returns the gtag snippet that reports the app's conversions to Google Ads.

The snippet loads Google's tag, sets consent to denied for every purpose until the app grants it, captures the click ID from the landing URL into a first-party cookie once ad storage is granted, and reports a page view on each in-app route change. It carries the conversion ID of the first goal on the account whose tag Google has published, which covers every goal on that account.

Place the snippet once in the app's HTML rather than per page. Firing an individual conversion is separate. The app calls gtag('event', 'conversion', ...) at the moment the conversion happens, or you report it from the server with Upload Google Ads conversions.

<Note>This endpoint accepts a personal API key. Workspace API keys are not authorized for it and are rejected with a 403.</Note>

get/api/apps/{app_id}/google-ads/tracking-script

Path parameters

app_idstring required

ID of the app whose Google Ads conversion tracking you want to manage.

ID of the app whose Google Ads conversion tracking you want to manage.

Response

The snippet to place in the app.

scriptstring nullable required

The gtag snippet, wrapped in a <script> tag and ready to place in the app's HTML, or null when no goal on the account has a published tag yet. Build Google Ads tracking fix prompt creates the goals, and Google takes a few minutes to publish each tag, so a null straight after setup means you should read this again shortly.

Example response

{
  "script": "<script>\nwindow.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'AW-123456789', {'send_page_view': false});\n</script>"
}

Changes

Changed in 1 of the 2 revisions of this API.1