+ Start a Discussion

Lightning component error: SecureElement does not allow access to async throws

I'm trying to get Google Tag Manager working with a Lightning Community. This involves getting a script and iframe into the site as per https://developers.google.com/tag-manager/quickstart

Script can't be put into the community head markup or branding css, so I created 2 Lightning components as follows:

Header component
<aura:component implements="forceCommunity:availableForAllPageTypes">
    <ltng:require scripts="{!$Resource.googletagmanager}"/>

Body component
<aura:component implements="forceCommunity:availableForAllPageTypes">
    <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
    height="0" width="0" style="display:none;visibility:hidden"></iframe>

The header component gives me an error as follows:

Uncaught Error: SecureElement does not allow access to async throws at https://myorg--livepreview.instance.force.com/mycommunity/s/sfsites/auraFW/javascript/egTJsAb7_Esngaq3zUvPDw/aura_prod.js:8:15

It looks like Lightning Components doesn't like the async attribute in the GTM script? If so, can I somehow get them to be friends? I can remove async from the script but I don't know how this will affect GTM. Anyone needed to do this before?
Martin ProkopMartin Prokop
I have same issue
Biao TianBiao Tian
I have the same issue when integrating Piwik JS to a lightning component.