Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #269484

    Hi!

    I work a lot with Google Tag Manager. I am programming a serie of tags to track user behaviour (time to read a post, type of user taking into consideration the previous metric and the number of words of a post (scanner, reader, intensiv reader…), identify users that comment, that share content in social networks…)

    I would like to fire these tags only in posts (not in pages or other elements). I could use the URL as a firing rule, but I should update those rules every time I add new categories. As you know the whole code better than me, maybe you can help me saying of the following approach should be ok:

      The id=”top” is unique and is always in the element body.
      The class “single …” is used only in posts
      body always have an id top and its corresponding class

    If those arguments are true, then I can use the class of the body element to identify posts and send the Google Tag Manager Tags (document.getElementById(“top”).className;)

    Thank you!!

    Agustín

    #269764

    Hi Agustin!

    Yes, that would work, Posts also receive the ID in a class like postid-xx in case you wanted to target a specific Post.

    Regards,
    Josue

    #270560

    Thanks Josue! Is this postid-xx class a special Enfold’s Feature or it is part of WordPress vanilla code?

    Best Regards,
    Agustin

    #270569

    Hey!

    Its part of the WordPress body class function: http://codex.wordpress.org/Function_Reference/body_class

    Best regards,
    Devin

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