Skip to content
English - United Kingdom
  • There are no suggestions because the search field is empty.

Checkout redirect

Setup redirect after checkout session has been completed through Google Tag Manager

1. The Core Components

To make anything happen in GTM, you need three things:

  1. The Tag: What you want to happen (the JavaScript redirect).

  2. The Trigger: When you want it to happen (on a specific page load).

  3. The Variable: Information GTM needs to identify the page (usually the Page Path).

 

2. Step-by-Step Setup

Phase A: Create the Trigger

We need to tell GTM exactly which page should trigger the redirect.

  1. Log in to your GTM container and click Triggers > New.

  2. Name it: Page View - Redirect Source.

  3. Click Trigger Configuration and choose Page View.

  4. Under "This trigger fires on," select Some Page Views.

  5. Set the condition to: Page Path + equals + /redirect-page-url.

  6. Hit Save.

Phase B: Create the Redirect Tag

Now, we tell GTM what to do when that trigger is pulled.

  1. Click Tags > New.

  2. Name it: JS - Page Redirect.

  3. Click Tag Configuration and select Custom HTML.

  4. Paste the code snippet into the box: (Replace the URL with your wished destination)

  5. Click Triggering and select the trigger you created in Phase A (Page View - Redirect Source).
  6. Hit Save.
<script>
window.location.href = 'https://www.yourdomain.com/new-destination-page';
</script>

3. Testing and Going Live

Don't skip this. If you mess up the URL, you could create a redirect loop or send users to a 404 page.

  • Preview Mode: Click the Preview button in the top right of GTM. Enter your website URL. A new tab will open with the "Tag Assistant."

  • Verify: Navigate to the "old" page. If everything is correct, the page should immediately redirect you to the new one. In the Tag Assistant window, you should see your tag under "Tags Fired."

  • Publish: Once you’re 100% sure it works, go back to the main GTM tab and click Submit. Give your version a name (e.g., "Added redirect for old promo page") and click Publish.

 

⚠️ Important Considerations

  • SEO Impact: A JavaScript redirect is a "302 (Temporary) Redirect" in the eyes of search engines. If this move is permanent, a server-side 301 redirect is much better for your Google rankings.

  • Flash of Content: Because GTM loads after the page starts rendering, the user might see the old page for a split second before the redirect kicks in.

  • Infinite Loops: Ensure your "Trigger" does not match the "Destination" URL, or the page will just keep refreshing itself forever!

Pro Tip: If you want the redirect to happen faster, go to the Tag settings and set the Tag firing priority to a higher number (like 100), ensuring it jumps to the front of the line.

 

Checkout session endpoints

  • /CheckoutSession/SuccessfulPayment
  • /CheckoutSession/FailedPayment