google-analyticsgoogle-tag-manageramp-htmlamp-form

Connection amp-form event to Google Tag Manager Ads-conversion tag


I have a site with an amp-form. I want to track Google Ads conversions using amp-form's amp-form-submit-success event as documented here.

Google Tag Manager's AMP container seems to only support a few triggers like Click, Scroll, Timer etc. No custom trigger. I have therefore created a Ads Conversion tag without a trigger in the hope that I can somehow manually trigger it from the <amp-analytics> tag configuration itself.

One thing I've tried is add the the adwords tag directly into the <amp-analytics> config like this:


    <amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-123456&gtm.url=SOURCE_URL" data-credentials="include">
      <!-- Extra tag for form submission  -->
      <script type="application/json">
      {
        "vars" : {
          "gtag_id": "GTM-123456",
          "config" : {
            "GTM-123456": { "groups": "default" },
            "<Conversion ID>": { "groups": "default" }
          }
        },
        "triggers": {
          "C_fm2EfIAdnpI": {
            "on": "amp-form-submit-success",
            "vars": {
              "event_name": "conversion",
              "send_to": ["<Conversion ID>/<Conversion Label"]
            }
          }
        }
      }
      </script>
    </amp-analytics>

The code above is based on the installation code generated for me by Google Ads. I've just tried to replace the click event with the amp-form event. This is the standard code:


    "C_fm2EfIAdnpI": {
      "on": "click",
      "selector": "CSS_SELECTOR",
      "vars": {
        "event_name": "conversion",
        "send_to": ["<Conversion ID>/<Conversion Label"]
      }
    }

I get an error from my code saying that the trigger is lacking a request property (which it is). But I have no idea what that request url would be.

Has anyone managed to hook up amp-form-submit-success to Google Ads Conversion? With or without using Google Tag Manager?

Do GTM AMP containers only support the built in Click, Scroll, Timer (etc) triggers and nothing else?


Solution

  • You can access the requests GTM provides you if you just open the JSON file in the config url. In your example: https://www.googletagmanager.com/amp.json?id=GTM-123456&gtm.url=SOURCE_URL (I would suggest you don't share your GTM id here).

    If you created any triggers in you GTM console you'll get a requests property with a list of endpoints for each trigger. So you can create a "fake" trigger and then just use that request.