Cloudflare rocket loader - Uncaught SyntaxError: illegal character U+2018

Hello,

i noticed today on both of my websites the error Uncaught SyntaxError: illegal character U+2018

    Uncaught SyntaxError: illegal character U+2018
    i https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:8
    u https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:10
    forEach https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:8
    u https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:10
    render https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:10
    render https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:10
    handle https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    r https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    handle https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    force https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    factory https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:13
    emit https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:8
    w https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    E https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    c https://mydomain.com/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js:1
    addEventListener https://mydomain.com/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js:1
    addEventListener https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:8
    addOnClickListener https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    render https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    render https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    f https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    c https://mydomain.com/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js:1
    addEventListener https://mydomain.com/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js:1
    addEventListener https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:8
    addOnClickListener https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    render https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:11
    handle https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:12
    onreadystatechange https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:9
    createRequest https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:9
    createHttpRequest https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:9
    sendRequest https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:9
    setTimeout handler*n/this.sendRequest https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:9
    handle https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:12
    bootstrap https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:13
    <anonymous> https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:13
    <anonymous> https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.js:13

I use on both of my websites cloudflare together with cloudflare rocket loader. I have te following Piwik Async Code in the header of my websites:

<!-- Piwik Tag Manager -->

<script type="text/javascript">

(function(window, document, dataLayerName, id) {

window[dataLayerName]=window[dataLayerName]||[],window[dataLayerName].push({start:(new Date).getTime(),event:"stg.start"});var scripts=document.getElementsByTagName('script')[0],tags=document.createElement('script');

function stgCreateCookie(a,b,c){var d="";if(c){var e=new Date;e.setTime(e.getTime()+24*c*60*60*1e3),d="; expires="+e.toUTCString()}document.cookie=a+"="+b+d+"; path=/"}

var isStgDebug=(window.location.href.match("stg_debug")||document.cookie.match("stg_debug"))&&!window.location.href.match("stg_disable_debug");stgCreateCookie("stg_debug",isStgDebug?1:"",isStgDebug?14:-1);

var qP=[];dataLayerName!=="dataLayer"&&qP.push("data_layer_name="+dataLayerName),isStgDebug&&qP.push("stg_debug");var qPString=qP.length>0?("?"+qP.join("&")):"";

tags.async=!0,tags.src="https://example.containers.piwik.pro/"+id+".js"+qPString,scripts.parentNode.insertBefore(tags,scripts);

!function(a,n,i){a[n]=a[n]||{};for(var c=0;c<i.length;c++)!function(i){a[n][i]=a[n][i]||{},a[n][i].api=a[n][i].api||function(){var a=[].slice.call(arguments,0);"string"==typeof a[0]&&window[dataLayerName].push({event:n+"."+i+":"+a[0],parameters:[].slice.call(arguments,1)})}}(i[c])}(window,"ppms",["tm","cm"]);

})(window, document, 'dataLayer', 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx');

</script><noscript><iframe src="https://example.containers.piwik.pro/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/noscript.html" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

I copied yet the async code again, and tried also to set for the script data-cfasync=“false” like this:

Is Piwik Pro not working correctly with Cloudflare Rocket Loader ? Do i have somewhere in the Code some Error, how can i get this fixed? Thx! Sall

Hi. Does it work without the rocket loader?

Hello,

no, i get still the same error even when Cloudflare Rocket Loader is deactivated

Any Idea how to solve ?

Thx!

Isn’t cloudflare just loading a static HTML? What’s the difference comparing to a standard website? Can you maybe share the URL where you tried to install the code?

Hello,

thanks for your reply. I send you the URL via PM.

Thanks. It’s installed correctly but you have the standard Piwik PRO tag misconfigured. The trigger was updated, not sure if it was intended. Currently it fires after each mouse click which will generate lots of redundant page views. You can check in tracker debugger if traffic flows in.

Your site is also configured to gather data only after consent, so make sure that you accepted tracking before checking if it works.

Thanks for the update. yes, the trigger fires after each click, is this not correct ? When i check with tracker debugger traffic flows in.

The Uncaught Syntax Error illegal character U+218 pops up after i Agree to All.

How can i fix the error?
Thx

Piwik PRO tag should be fired on each page view, not on each click.

As for the error - there was a typo in the code while defining the datalayer of a/b testing tag. Also, keep in mind that curly bracers {{ }} are used only to access variable values. If you simply need to pass a number, just type it in. For instance, in the goal configuration you should put 1 instead of {{ 1 }}.

Hello Kuba,

thanks a lot for the information, and help with the setup regarding the pageviews / info about the bracers. I adapted the settings of my other domain now similar per your recommendations but i get there still some other error

Uncaught SyntaxError: missing } after property list
note: { opened at line 3, column 24

Any chance to get this error also fixed?

Thank you.

User_Feedback_Consent tag had invalid javascript in the datalayer definition.

As for the third site, I can see that you installed the container code twice. It should start working after fixing that.