Create Meta Refresh Meta Tag with Tag Manager (GTM)

Sitebee

Technical SEO
Staff member
Create and deploy a meta refresh redirect tag using Google Tag Manager. If you need to deploy a meta refresh redirect on a webpage but do not have access to the codebase or the CMS administration, then this handy guide will help you inject a meta refresh redirect using Google Tag Manager.

Code:
 <meta http-equiv="refresh" content="500;url="https://example.com/">

This guide assumes that you already know the basics on how to create tags and triggers in GTM. If not, I recommend that you go learn the basics of Google Tag Manager first.

Step 1
Create a new GTM Tag set to tag type Custom HTML. Label the tag whatever suits your needs. In this example, I have called the tag Meta Refresh Tag.

Step 2
Copy and paste the script snippet below in to the HTML box. Then you will want to edit the meta refresh redirect from 500 (seconds) to something more reasonable. 5 seconds is a popular choice for meta redirects.

You also need to update the example URL to point at the target URL that you want to redirect too.

Code:
<script>
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'refresh');
meta.content = '500;url="https://example.com/';
jQuery('head').append(meta);
</script>

meta-refresh-tag.PNG


Step 3
Now it is time to set the triggering rules for your newly created meta refresh tag. Shift down to the Triggering box below the Tag Configuration box. On the Choose a Trigger selection menu, click the plus icon ( + ) in the top right. This will launch the Trigger Configuration box.

Choose trigger type - select the DOM Ready in Page View.
meta-refresh-tag1.PNG


Set the trigger firing to 'Some DOM Ready Events', the trigger conditions are Page URL > Equals and for the last triggering conditions box set it to the URL that you want to set the meta redirect refresh on (if you want to trigger it sitewide, use the All DOM Ready Events trigger instead) without the domain host name. Example: /URI-GOES-HERES

meta-refresh-tag2.PNG


Save the trigger and give it a trigger name and save the tag again. Now we're ready to republish the GTM container. Go ahead and do just that.
meta-refresh-tag3.PNG


Final Step
Once you've republished the GTM container. Head to the page (or pages) that you have set the meta refresh redirect GTM tag on. Did it redirect? If So then it has worked. If not, viewed the rendered HTML to check if the attributes are set correctly.

refresh.PNG


Comment below if you encountered any issues.
 
Last edited: