Skip to main content
SnippetsJavascript

On Page Load Append Param to URL

By May 30, 2020No Comments

Basically just append a parameter to the location (URL) when page loads. In the example below I am including a WordPress page title in the URL.

var your_message = <?php echo json_encode(get_the_title());?>;
if(window.location.search.indexOf('?') === -1) {window.location.search += '&your-message=I would like to learn more about your '+your_message+' :)';}

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton