I'm getting the following error message in Google Tag Manager:
Error at line 6, character 282: this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
when adding this Inter snippet tag
<script>
window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>
<script>
(function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; function l() { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>
For this section of the code i = function () {
I'm getting the following error message in Google Tag Manager:
Error at line 6, character 282: this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
when adding this Inter snippet tag
<script>
window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>
<script>
(function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; function l() { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.inter.io/widget/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>
For this section of the code i = function () {
- 1 Please don't include images of text, you need to include the text directly in the question. Google Tag Manager allows you to inject code (tags) into the users browser session: someone has written a tag that uses a version of JS too new for the target browser. – Richard Commented Feb 22, 2018 at 8:39
- Please include the code here. – Harun Diluka Heshan Commented Feb 22, 2018 at 8:41
- Hey guys, Okay thanks for the information - I thought it would be easier to isolate the character with an image. – Charlie Howes Commented Feb 22, 2018 at 9:09
- Possible duplicate of Why am I getting a JavaScript piler error when trying to publish changes to my inter tag in Google Tag Manager? – nyuen Commented Feb 23, 2018 at 1:08
- This is possibly a duplicate of stackoverflow./questions/48440623/… – nyuen Commented Feb 23, 2018 at 1:09
2 Answers
Reset to default 4This worked for me in Google Tag Manager:
<script>
window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>
<script>
(function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.inter.io/widget/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>
What has changed here is that
function l() { ... }
has been changed to
var l = function () { ... };
You need to declare a variable using the var keyword.
You currently pare something to a non-existing variable, you also use strict equality, which is impossible because there is no type to qualify the strict equality to, vinoaj workaround is what you want.