title: Modify theme.liquid using Shopify API
body: <p>I am looking to add a <code>javascript</code> snippet for some analytics across the store using the <a href="https://docs.shopify.com/api" rel="nofollow">Shopify API</a>. I figured out that using <code>admin/themes/:id/assets.json</code> I can modify the <code>theme.liquid</code> to insert snippet but this changes the entire content of the page. The current API call that I do is </p>
  
  <pre><code>admin/themes/35073539/assets.json
  {
    "asset": {
      "key": "layout\/theme.liquid",
      "value": "{{content_for_header}}&lt;script&gt;console.log('foo')&lt;/script&gt;"
    }
  }
  </code></pre>
  
  <p>This obviously doesn't work.</p>
  
  <p>I just want to modify the <code>&lt;head&gt;</code> tag and insert some custom <code>javascript</code>. Also, <code>ScriptTag</code> won't be useful as I have to take some input from user, use that input in my <code>javascript</code> and then insert the snippet. Any help would be appreciated.</p>