Get Google Ads tracking script
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.
Authorizations
Personal API key.
Path Parameters
ID of the app whose Google Ads conversion tracking you want to manage.
Response
The snippet to place in the app.
The gtag snippet that reports the app's conversions to Google Ads.
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.
"<script>\nwindow.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'AW-123456789', {'send_page_view': false});\n</script>"