google analytics: how to set up a custom dimension with GA + GTM to distinguish pages with and without buttons


Hello to all who read this. With Google Analytics and Google Tag Manager, the goal I am trying to achieve is to configure a custom dimension that allows you to distinguish between pages that contain buttons and pages that do not contain buttons, as shown in the example table below.

example table

This would let me know that a page like PAGE B it has no button clicks because it has no buttons and that a page like PAGE D It has no button clicks because there is something that needs to be repaired or improved.


In Google Analytics

  1. A custom dimension was created: scope hit active yes, and the index number of 1 It was observed.

In Google Tag Manager

  1. A variable called "Button visibility" was created: variable type item visibility, item selector buybtn (button class), output type true False, minimum visible percentage fifty, format value turn true to yes, convert false to no.

    1. The Google Analytics configuration variable was edited to have a custom dimension with index number one and the value of the dimension {{Button visibility}}

Additional Information

There are other tags and triggers that are configured and work correctly, since GTM tracks daily button click events and GA informs them, which means the buttons are entering the user's graphic window, but for some reason , when viewing GA and choosing the custom dimension, there is no data and when previewing the website through GTM, the visibility variable of the button is null, although there are several buttons present in the graphic window. I also tried to change the scope of the session, but no tracking occurs and the visibility of the button variable remains nil.


If you have any suggestions on how to solve this problem, preferably without using the data layer, or if you could guide me in the right direction through tutorials, I would appreciate your support.