Title: Interstitial JavaScript Redirect with Redirection
Last modified: March 9, 2020

---

# Interstitial JavaScript Redirect with Redirection

 *  Resolved [weismannweb](https://wordpress.org/support/users/weismannweb/)
 * (@weismannweb)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/)
 * Hi,
 * I created this GIST because I wanted to load some javascript before redirecting
   so I could track visitors via Facebook Pixel, Mautic, Google Analytics etc etc.
 * If your site outputs those tracking codes in the header or footer then you just
   need to change the redirect from server-side to javascript on the client-side
   and probably wait 3 or so seconds for the js to load. So that is what I have 
   done with the GIST below.
 * If the author of the plugin is interested in having this in the core codebase
   I can add a field for which page to use and a new redirect type that inherits
   WordPress redirect type. IF not I may try and find time to make a plugin for 
   it. Either way only if anyone is interested. Thanks!
 * [https://gist.github.com/weismannweb/f1febe71e9f638d7d31464247d357961](https://gist.github.com/weismannweb/f1febe71e9f638d7d31464247d357961)
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Finterstitial-javascript-redirect-with-redirection%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/#post-12523441)
 * Thanks for the work, and I hope it proves useful to people.
 * One note is that these interstitial pages aren’t really redirects, and only work
   for browsers. The original page still exists, will return a HTTP 200 code, and
   will be indexed by Google.
 * There is a feature request to do this in a way that doesn’t require JavaScript:
 * [https://github.com/johngodley/redirection/issues/477](https://github.com/johngodley/redirection/issues/477)
 * I would add some output escaping to the URL in your gist otherwise you could 
   create a security issue.
 *  Thread Starter [weismannweb](https://wordpress.org/support/users/weismannweb/)
 * (@weismannweb)
 * [6 years ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/#post-12593168)
 * There was an issue with logging into the admin. So now I am doing it only if 
   it is a redirection redirect with a target. Also, I am using that to get the 
   target URL too now using the hook redirection_url_target. I will add output escaping
   later. Unfortunately, this will add an interstitial to all redirection redirects.
   Maybe in the future, I will add a setting to redirects to do an interstitial 
   only for some based on selecting which ones. I dont ne3ed a real redirect. I 
   am only using redirection for my own short url service. The WordPress is otherwise
   blank.
 *  Thread Starter [weismannweb](https://wordpress.org/support/users/weismannweb/)
 * (@weismannweb)
 * [6 years ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/#post-12593232)
 * John,
 * Is there a hook to add when matched option. If not then maybe I should use a 
   group?: [https://prnt.sc/ro1pkr](https://prnt.sc/ro1pkr)
 * Is there a hook to get the group a redirect belongs to? Can we get it from source
   or target hooks or some other hook?
    -  This reply was modified 6 years ago by [weismannweb](https://wordpress.org/support/users/weismannweb/).
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [6 years ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/#post-12597245)
 * All hooks are listed here:
 * [https://redirection.me/developer/wordpress-hooks/](https://redirection.me/developer/wordpress-hooks/)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Interstitial JavaScript Redirect with Redirection’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

## Tags

 * [interstitial](https://wordpress.org/support/topic-tag/interstitial/)
 * [Tracking Codes](https://wordpress.org/support/topic-tag/tracking-codes/)

 * 4 replies
 * 2 participants
 * Last reply from: [John Godley](https://wordpress.org/support/users/johnny5/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/interstitial-javascript-redirect-with-redirection/#post-12597245)
 * Status: resolved