title: Google tag manager Custom Template and Amplitude event logging
body: <p>I'm trying to use the amazing features brought by the Custom Template on Google Tag Manager to organize the tags we use to log events on Amplitude.</p>
  <p>I used to have a code like : amplitude.getInstance().logEvent(eventTitle, {args})</p>
  <p>However, due to sandbox javascript we do not have direct access to amplitude.</p>
  <p>So I tried to do:</p>
  <pre><code>const callInWindow = require('callInWindow');
  const copyFromWindow = require('copyFromWindow');
  
  const amplitude = copyFromWindow('amplitude');
  callInWindow('amplitude.getInstance().logEvent', eventTitle, args);
  </code></pre>
  <p>And I gave full permissions on :</p>
  <ul>
  <li>amplitude</li>
  <li>amplitude.getInstance</li>
  <li>amplitude.getInstance.logEvent</li>
  </ul>
  <p>But the result is a tag failing with error saying : Tag XXX threw an error</p>
  <p>The only workaround I found is to use a deprecated version of the API: amplitude.logEvent in the following way.</p>
  <pre><code>const callInWindow = require('callInWindow');
  const copyFromWindow = require('copyFromWindow');
  
  const amplitude = copyFromWindow('amplitude');
  callInWindow('amplitude.logEvent', eventTitle, args);
  </code></pre>
  <p>And it works properly but I don't know for how long based on the deprecation announced by Amplitude : <a href="https://amplitude.github.io/Amplitude-JavaScript/Amplitude#amplitudelogevent" rel="nofollow noreferrer">https://amplitude.github.io/Amplitude-JavaScript/Amplitude#amplitudelogevent</a></p>
  <p>Does anyone know how I could in js sandbox first get the instance of amplitude.getInstance and then call used it's logEvent feature?</p>
  <p>Your help would be highly appreciated.</p>
  <p>Cheers!</p>