title: Rewrite and redirect a url with variables and google tag manager
body: <p>I am using a booking system on my website. The form gets proccess on a second page because I need a custom url to be written using the variables from the form. The form is being hosted in the header.php page of a wordpress website. Once they click submit, they are taken to a page with the following code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$TheLink = 'https://demo.reztrip.com/search?' . '&amp;arrival_date=' . date("Y-m-d", strtotime($_GET['date'])) . '&amp;departure_date=' . date('Y-m-d', strtotime($_GET['date'] . " + {$_GET['nights']} days"));
     header( "Location: $TheLink" ) ;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The client is requesting that the google analytics get carried over to the redirect. </p>
  
  <p>I understand I cannot just add them to this second booking page because it his a redirect and no other code will be processed. </p>
  
  <p>I have looked into meta redirects or js redirects but I get lost at combining my php to rewrite the url and the js to redirect.</p>
  
  <p>Is there a simpler way to achieve the redirect with the rewritten url with the google tags getting carried over?</p>