Error : this language feature is only supported for ECMASCRIPT6 mode or better 【Google Tag Manager】


When I create a custom-html tag in Google Tagmanager I get this error:

JavaScript Compiler Error Typeform Tag Error at line 11, character 22: This language
feature is only supported for ECMASCRIPT6 mode or better: const declaration.

The same error occurs for line 22.

This is my code:

 function formatDate(dt) {
    var y = ('00'+dt.getFullYear()).slice(-2);
    var m = ('00' + (dt.getMonth()+1)).slice(-2);
    var d = ('00' + dt.getDate()).slice(-2);
    var h = ('00' + dt.getHours()).slice(-2);
    var mm = ('00' + dt.getMinutes()).slice(-2);
    return (y  + m + d +  h  + mm);
 nowDate = formatDate(new Date());
 const getAfbItem = `${nowDate}`;

if (!window.dtlpcvCvConf) {
  window.dtlpcvCvConf = [];
  siteId: "",
  commitData: {
    pid: "",
    amount: "",
    mid: "",
    u: `${getAfbItem}`, 

Please, share your thoughts or any advices, would highly appreciate it! – thanks you in advance.


Template literals (with the `) were introduced in ES6.

Since you are only using it as ${<variable>}, you are probably fine with just <variable>, you don’t need to put it in a literal. If it isn’t already a string, you can convert it to a string with ""+<variable>.

const and let similarly were introduced in ES6, just replace them with var. They behave slightly differently, but it is fine for most use-cases.

I’m not familiar with GTM, but this is probably a restriction to reach the widest audience possible.

Answered By – Consti P

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.