'How can I make my JavaScript code work in AMP

Here is the JavaScript I want to work in my AMP:

<script type="text/javascript">

    atOptions = {
        'key' : '86636a40c1b6dd3eeaa4c56ec9c7ba77',
        'format' : 'iframe',
        'height' : 90,
        'width' : 728,
        'params' : {}
    };
    document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://backstagedeputy.com/86636a40c1b6dd3eeaa4c56ec9c7ba77/invoke.js"></scr' + 'ipt>');

</script>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source