Search code examples
google-tag-manager

How to collect data based on meta name on tag manager


I have about 100 internet pages that have the same <meta name>, which is

<meta name="topic" content="dogs" />

I want to know how many pages, containing that meta name (dogs), were visited (pageviews).

Can someone help me coding this custom variable? (I am not a developer...)


Solution

  • Go to Variables->User Defined Variables -> New.

    • Select "DOM Element" as variable type.

    • Select "CSS Selector" as selection method.

    • As Selector, enter meta[name=topic].

    • As Attribute name, enter "content".

    • the variable now returns the value of the content attribute

    You can access DOM elements only after they have been rendered, but usually the GTM snippet is below meta elements, so this will probably not be a concern.