title: Pass parameters - Shopify Script Tag API
body: <p>I'm posting a solution to this question since I didn't find a precise answer to this. It might be useful to someone.
  Here's what needs to be done.</p>
  
  <p>Pass your data in the form of query string params.Example, <code>https://web.page.com/yourFile.js?param1=something&amp;paramm2=something</code>. 
  Also, note that the <code>shop=</code> param is automatically appended to the final version of your script that is injected on the Shopify's liquid template.</p>
  
  <p>Final version of the script in the template looks something like this.
  <code>&lt;script type="text/javascript" async="" src="https://web.page.com/yourFile.js?param1=something&amp;paramm2=something&amp;shop=yourshop.myshopify.com"&gt;&lt;/script&gt;</code></p>
  
  <p>Once this is done, get the final <strong>URL</strong> (containing params) in <code>yourFile.js</code> in the following way.
  <code>var url = document.getElementsByTagName("script")[0].src</code></p>
  
  <p>Now, using the method below, you can get the values of your parameters.</p>
  
  <pre><code>function getParameterByName(paramName, url) {
      if (!url) url = window.location.href;
      name = name.replace(/[\[\]]/g, "\\$&amp;");
      var regex = new RegExp("[?&amp;]" + name + "(=([^&amp;#]*)|&amp;|#|$)"),
          results = regex.exec(url);
      if (!results) return null;
      if (!results[2]) return '';
      return decodeURIComponent(results[2].replace(/\+/g, " "));
  } 
  </code></pre>