How To Test Structured Data Tags in GTM Preview Mode

Before you publish a container in Google Tag Manager it’s important to check that your tags are working perfectly to avoid any unexpected errors. Fortunately, Google Tag Manager provides a native Preview mode. However, when it comes to structured data markup, it can be a little challenging to test before publishing.

This post outlines a useful trick that we use here at UpBuild to test our structured data tags using Google’s Structured Data Testing Tool while your container remains unpublished.

First, make sure you’re using the Google Chrome browser.

Once you’re ready to test, navigate to the Google Tag Manager container which has your structured data tag. Then go ahead and enter Preview mode by clicking the button in the top-right of your Google Tag Manager workspace. You should see a notification that looks just like this:

Next, you’ll need to navigate to the page that you are planning to deploy your structured data tag onto. When you’re in Preview mode in Google Tag Manager, you should see the Debug panel at the bottom of your browser window:

Note that quite a few modern ad blockers and privacy extensions (including Ublock Origin) will block any request to any Google website — even to Google Tag Manager. If you’re not seeing the Debug panel, you may need to turn off your adblocker.

If your tag is firing correctly, it should display under the “Tags Fired On This Page” section. Notice that in the example above we have our structured data markup inside the “JSON-LD Organization Info” tag.

With that confirmed, we can now right-click anywhere on the page itself and then choose “Inspect” to open up the Elements panel in Google Chrome DevTools. You can also use shortcuts, Command+Option+C on Mac or CTRL+Shift+C on Windows/Linux.

From there you will want to grab all of the rendered HTML on the page in its current Preview state. To do this you can simply click the three dots where the <html line begins then choose “Edit as HTML”. This will allow us to select all of the HTML code between the opening <html> and closing </html> tags on the page. You can also select “Copy” > “Copy Element” to accomplish all of this in one step:

If done correctly the window should become editable:

Next, select and copy all of the HTML code to your clipboard use Command+A then Command+C on Mac, or CTRL+A then CTRL+C on Windows/Linux.

Now, all we need to do is head over to Google’s Structured Data Testing Tool, toggle the pop-up window from FETCH URL to CODE SNIPPET, and paste our HTML code into the input field where it reads “Paste your code”:

All that’s left to do now is click the RUN TEST button.

If everything goes as expected you should see the tag containing your structured data deploying in the tool, all without the need to publish the container.

This method can help you find errors and double-check that your structured data tags will launch as expected.

How to Test Clicks and Forms Without Submitting Data

There are also tools such as GTM Sonar which can be used to help Google Tag Manager listen for clicks and even form submissions without actually recording a click or submitting a form. This can help you avoid messing up your Analytics data or CRM’s with inflated clicks or test forms. Sale’s reps everywhere rejoice!

GTM Sonar was created by Simo Ahava, an expert in Google Analytics and Google Tag Manager. Simo has a bunch of other great Google Tag Manager tools that we recommend checking out.

If you have any other great resources or tips on testing Google Tag Manager before publishing a container I’d love to hear about them in the comments below.

Related Posts

Leave a Reply

Your email address will not be published.