Chip Oglesby and Julien Coquet shared their amazing guides on the topic of outputting WordPress variables into to Google Tag Manager’s dataLayer. I’d just like to save your time when you decide to make them work with Divi or Extra.

Why bother?

Having dataLayer on your WordPress site is vital, because it simplifies measurement via Google Tag Manager (GTM), especially when it comes to content grouping.

When it comes to implementing Julien’s or Chip’s scripts, there is one question a non-developer struggles with. Where exactly should I paste the code into the WP files, so the theme doesn’t break? Here are some suggestions.

Extra

  1. Go to single-post.php
  2. Find the </article> tag
  3. Paste the dataLayer code underneath the tag
  4. Save the file

Divi

  1. Go to single.php
  2. Find the </div> <!– .et_post_meta_wrapper –>¬†tag
  3. Paste the dataLayer code underneath the tag
  4. Save the file

The Code

Don’t forget to get check the script in a post’s source code. If you don’t see it there, chances are something went wrong.

You can now complete the Tag Manager set-up using Chip’s guide.

Disclosure: Links to Divi and Extra are affiliate.