Support » Plugin: AMP » Google Analytics not populating Event Category and Event Action

  • Resolved Bub

    (@jdenning47)


    Google Analytics tag fires but does not populate “Event Category” and “Event Action” when using Google Tag Manager. If I put the same tag using the AMP plugin Analytics it the “Event Category” and “Event Action” show up as expected. Can you give me any help with using GTM?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    Thanks for reaching out. If the setup is working when added via the Analytics feature within the AMP plugin then it sounds like it may be a configuration issue.

    Can you share how you implemented Google Tag Manager on your site, did you manually insert into your theme files? If so have you tried using the Site Kit plugin by Google? That way you can configure your AMP container with ease, using the Tag Manager web interface.

    Thread Starter Bub

    (@jdenning47)

    I have experimented with

    • Google Site Kit with GTM. Tag Fires no Event Cat. or Event Act..
    • Google Site Kit without GTM enabled and inserted the AMP and GTM snippets. Tag Fires no Event Cat. or Event Act..
    • Google Site Kit without GTM enabled and inserted tag code into the Analytics block within the plugin tab Tag Fires and loads Event Cat. and Event Act..
    • {
          "vars": {
              "gtag_id": "UA-109333845-9",
              "config": {
                  "UA-109333845-9": { "groups": "default" }
              }
          },
          "triggers": {
              "button": {
                  "selector": "#the-button",
                  "on": "click",
                  "vars": {
                      "event_category": "ButtonClick",
                      "event_name": "clicking on button",
                      "event_label": "my button",
                      "method": "Google"
                      }
                  }
          }  
      }
      

      This is what the not populating tag looks like in GTM
      Tag Configuration
      Tag Type

      Google Analytics: Universal Analytics
      Google Marketing Platform
      Tracking ID
      UA-xxxxxxxxx-x
      Track Type

      Event
      Event Tracking Parameters
      Category
      ButtonClick
      Action
      click
      Label
      button left
      Value
      1
      Non-Interaction Hit

      True

      ____________
      Trigger Configuration
      Trigger Type
      Click
      CSS Selector (specific elements this click applies to)
      #the-button
      This trigger fires on
      All Pages

    Plugin Support James Osborne

    (@jamesosborne)

    Thanks for sharing the snippet. I don’t see anything wrong with the snippet you provided.

    Google Site Kit with GTM. Tag Fires no Event Cat. or Event Act..

    Have you applied a Universal Tracking ID Tag within an AMP container or are you using manually inserted Tag Manager snippets? You don’t need to manually insert any snippets using a Google Analytics Tag and publishing before then connecting via Site Kit.

    While we’re limited to AMP plugin support I’m happy to check your configuration if you want to share your site URL. Other than checking your setup may find better luck with events not firing as expected with the Analytics product experts at the Analytics Help Center.

    Thread Starter Bub

    (@jdenning47)

    I just disconnected GTM from Site Kit and manually inserted GTM-AMP snippets as shown below. (I currently am using https://github.com/woocommerce/theme-customisations to insert these into functions.php within the storefront/boutique themes.)

    /** Add AMP code for Google Tag Manager after header*/
    add_action ('wp_head', 'add_google_tag_manager_for_AMP_after_header');
    function add_google_tag_manager_for_AMP_after_header() {
    ?>
    <!-- AMP Analytics --><script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
    <?php
    }
     
    /** Add AMP code for Google Analytics Tag after opening body tag */
    add_action( 'wp_body_open', 'add_google_tag_manager_for_AMP_after_body_tag' );
    function add_google_tag_manager_for_AMP_after_body_tag() {
    ?>
    <amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-xxxxxxx&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics>
    <?php
    }

    I am using the previously mentioned gtag tag code used within the plugin analytics tab and am seeing in Google Analytics:
    Event Category: ButtonClick with Event Action: clicking on button

    {
        "vars": {
            "gtag_id": "UA-XXXXXXXXX-X",
            "config": {
                "UA- XXXXXXXXX-X ": { "groups": "default" }
            }
        },
        "triggers": {
            "button": {
                "selector": "#the-button",
                "on": "click",
                "vars": {
                    "event_category": "ButtonClick",
                    "event_name": "clicking on button",
                    "event_label": "my button",
                    "method": "Google"
                    }
                }
        }  
    }

    NEXT:
    I remove the gtag code snippet above from the AMP plugin Analytics and again run the following from Google Tag Manager:
    Tag Configuration
    Tag Type: Google Analytics: Universal Analytics Google Marketing Platform
    Tracking ID: UA- XXXXXXXXX-X
    Track Type: Event
    Event Tracking Parameters
    Category: ButtonClick
    Action: click
    Label: button left
    Value: 1
    Non-Interaction Hit: True

    Trigger Configuration
    Trigger Type: Click
    CSS Selector (specific elements this click applies to): #the-button
    This trigger fires on: All Pages

    After clicking on the button Google Analytics Realtime Events shows:
    An Event Spike but indicates no Active User along with no Event Action or Active Users data
    After activating a standard All Pages tag and clicking the button I get an Active User and an event spike but still no Event Action or Active Users data.

    Plugin Support James Osborne

    (@jamesosborne)

    Thanks for the update. As you’ve already done as suggested and used the Universal Tracking tag within an AMP container the next step would be to contact the Analytics Help Center to enquire on any possible causes for event actions or active user data, or the Tag Manager Help Center for any possible issues with the AMP Universal Analytics tag.

    Sorry I can’t be of more assistance.

    Thread Starter Bub

    (@jdenning47)

    Thanks for your help. I will go with your suggestions above.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.