> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/api-reference/upload-google-ads-conversions).

<Warning>To wire tracking into a Base44 app, use `tracking_snippet` from [Build Google Ads tracking fix prompt](/api-reference/build-google-ads-tracking-fix-prompt) instead. That is the bootstrap the builder installs, and it follows the owner's visitor-tracking setting, while this snippet always starts consent as denied. Install one of the two, never both, or the app loads Google's tag twice.</Warning>

<Note>This endpoint accepts a personal API key or a workspace API key. A workspace API key acts as the workspace owner.</Note>



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json get /api/apps/{app_id}/google-ads/tracking-script
openapi: 3.1.0
info:
  title: Base44 App Management API
  version: 1.0.0
servers:
  - url: https://app.base44.com
security:
  - PersonalAccessTokenAuth: []
paths:
  /api/apps/{app_id}/google-ads/tracking-script:
    get:
      summary: Get Google Ads tracking script
      description: >-
        <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](/api-reference/upload-google-ads-conversions).


        <Warning>To wire tracking into a Base44 app, use `tracking_snippet` from
        [Build Google Ads tracking fix
        prompt](/api-reference/build-google-ads-tracking-fix-prompt) instead.
        That is the bootstrap the builder installs, and it follows the owner's
        visitor-tracking setting, while this snippet always starts consent as
        denied. Install one of the two, never both, or the app loads Google's
        tag twice.</Warning>


        <Note>This endpoint accepts a personal API key or a workspace API key. A
        workspace API key acts as the workspace owner.</Note>
      operationId: >-
        get_tracking_script_endpoint_api_apps__app_id__google_ads_tracking_script_get
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            description: >-
              ID of the app whose Google Ads conversion tracking you want to
              manage.
            title: App Id
          description: >-
            ID of the app whose Google Ads conversion tracking you want to
            manage.
          example: 6820f3a4e7b91d003c45a1f2
      responses:
        '200':
          description: The snippet to place in the app.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackingScriptResponse'
        '401':
          description: Missing or invalid credentials.
        '403':
          description: >-
            You don't have access to this app or the app does not exist. A
            missing app and an app you cannot reach are deliberately the same
            answer. Marketing setup, campaign edits, generation and resuming
            also return `app_marketing_not_allowed` when the app's owning
            workspace has the FERPA designation. Historical reads, pausing,
            deletion and financial settlement remain available.
        '429':
          description: >-
            `rate_limited`: The base limit is 1,200 requests in a minute from
            your account, shared across every Google Ads read that doesn't name
            its own limit. Some workspaces have a higher limit.
            `X-RateLimit-Limit` reports the enforced limit. Retry after
            `Retry-After` seconds. The `X-RateLimit-*` headers report the budget
            left.
          content:
            application/json:
              examples:
                rate_limited:
                  summary: rate_limited
                  value:
                    error:
                      code: rate_limited
                      message: Rate limit exceeded.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '503':
          description: >-
            Database temporarily unavailable (`database_unavailable`): the data
            cluster did not answer in time. Retry after the `Retry-After`
            seconds.
          headers:
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
              examples:
                database_unavailable:
                  summary: database_unavailable
                  value:
                    error:
                      code: database_unavailable
                      message: Database temporarily unavailable, please retry
                      details: {}
      security:
        - PersonalAccessTokenAuth:
            - read_only
        - WorkspaceApiKeyAuth:
            - read_only
        - WorkspaceApiKeyBearerAuth:
            - read_only
components:
  schemas:
    TrackingScriptResponse:
      properties:
        script:
          anyOf:
            - type: string
            - type: 'null'
          title: Script
          description: >-
            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](/api-reference/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: |-
            <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', 'AW-123456789', {'send_page_view': false});
            </script>
      type: object
      required:
        - script
      title: TrackingScriptResponse
      description: The gtag snippet that reports the app's conversions to Google Ads.
    StandardErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/StandardError'
          description: What went wrong.
      type: object
      required:
        - error
      title: StandardErrorEnvelope
      description: The error body returned in the standard envelope.
    StandardError:
      properties:
        code:
          type: string
          title: Code
          description: >-
            Stable machine-readable cause of the failure. Match on this, not on
            `message`.
          example: not_found
        message:
          type: string
          title: Message
          description: Human-readable explanation. It isn't a stable contract.
          example: App not found
        details:
          additionalProperties: true
          type: object
          title: Details
          description: >-
            Structured context for the failure, or an empty object when there's
            none.
          example: {}
      type: object
      required:
        - code
        - message
      title: StandardError
  securitySchemes:
    PersonalAccessTokenAuth:
      type: http
      scheme: bearer
      description: >-
        Personal access token, sent as `Authorization: Bearer <token>`. Each
        operation lists the permission it needs: `read_only` or `full_access`. A
        full-access token can call every operation. A read-only token can call
        only the operations that list `read_only`; anything else returns 403
        `read_only_credential_route_not_allowed`.
    WorkspaceApiKeyAuth:
      type: apiKey
      in: header
      name: api_key
      description: >-
        Workspace API key, sent as `api_key: <key>`. Each operation that accepts
        one lists what the key needs: a permission, `read_only` or
        `full_access`, like a personal access token, or a scope. A key without
        the scope gets 403 `workspace_api_key_scope_required`.
    WorkspaceApiKeyBearerAuth:
      type: http
      scheme: bearer
      description: >-
        Workspace API key, sent as `Authorization: Bearer <key>`. Accepted
        wherever `api_key` is, with the same permission.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.