title: Writing JS varibales to functions and content
body: <p>I am creating some JS that will detect the URL and assign variables based on the current path.</p>
  
  <p>The script will then write the variables to functions and other scripts on the page.</p>
  
  <p>Im pretty new to JS and having issues actually getting the variables into the other places. </p>
  
  <p>I can alert the variables but not sure how to get them to be added to the other scripts.</p>
  
  <p>Script so far.</p>
  
  <pre><code>&lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  
  &lt;script&gt;
  
  //define deafult id's and tags
  var defaultBotID = "xxxxxxxxxxxx";
  var defaultBotAdTag = "yyyyyyyyyyyyyyy";
  
  //define id's and tags for xxx section
  var anotherBotID = "aaaaaaaaaaaa";
  var anotherBotAdTag = "bbbbbbbbbbbbbbbb";
  
  //define the variables to be used on the page
  window.adBotID;
  window.adBotTag;
  
  
  //**************************
  // Check the current URL then assign id's and tags
  if (window.location.href.indexOf("xxxx") &gt; -1) {
              adBotID = anotherBotID;
              adBotTag = anotherBotAdTag;
      }  else {
              adBotID = defaultBotID;
              adBotTag = defaultBotAdTag;
      } 
  &lt;/script&gt;
  
  &lt;script type='text/javascript'&gt;
  googletag.cmd.push(function() {
  googletag.defineSlot('**NEED ADBOTTAG HERE**', [300, 250], '**NEED ADBOTID HERE**').addService(googletag.pubads());
  googletag.pubads().enableSingleRequest();
  googletag.enableServices();
  });
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div id='**NEED ADBOTID HERE**' style='width:300px; height:250px;'&gt;
  &lt;script type='text/javascript'&gt;
  googletag.cmd.push(function() { googletag.display('**NEED ADBOTID HERE**'); });
  &lt;/script&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>I have added the locations where i need the variables to be written.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks</p>