Time Delay a URL Redirect for Specific Page
I need to set a time delay redirect for a specific page. Reason is because we have a URL redirect on the specific page and it is not registering for a Google Analytic page visit conversion. So we need to have a short time delay on the page before the redirect starts.
I found the below code to use, but I prefer not to add the code to the specific page, but instead in the functions.php if this is the recommended route. (CODE FOR FUNCTIONS PHP FILE)
Any suggestions are greatly appreciated.
CODE TO USE (found this when doing some research)
!DOCTYPE html
html
body
script
setTimeout(myURL, 5000);
function myURL(){
window.open('http://www.samplewebsite.com/pageone');
}
/script
pWeb page loads after 5 seconds./p
/body
/html
CODE FOR FUNCTIONS PHP FILE
function js_code_page() {
if (is_page ('pageID')) {
?
script type=text/javascript
setTimeout(myURL, 5000);
function myURL(){
window.open('http://www.samplewebsite.com/pageone');
}
/script
?php
}
}
add_action('wp_head', 'js_code_page');