• I have been using for years matomo/piwik integration through json code in footer of amp pages. Since last version of ampforwp I get json script validation errors. The problem is that suddenly, the slashes in the code below get stripped when showing in html code of the page. I validate the code below in amp validator and then it gets borken, in the second example.

    <amp-analytics><script type="application/json">
    {
    	"triggers": {
    		"trackPageview": {
    			"on": "visible",
    			"request": "pageview"
    		}
    	},
    	"requests": {
    		"base": "https://www.102mg.ro/stats/matomo.php?idsite=1&rec=1&action_name=${title}&url=${sourceUrl}&rand=${random}&apiv=1&urlref=${documentReferrer}&res=${screenWidth}x${screenHeight}&lang=${browserLanguage}&gt_ms=${serverResponseTime}&cs=${documentCharset}&_cvar={\"1\":[\"errorName\",\"${errorName}\"],\"2\":[\"errorMessage\",\"${errorMessage}\"]}",
    		"pageview": "${base}"
    	}
    }
    </script></amp-analytics>

    Example 2, actual output in the page:

    <amp-analytics><script type="application/json">
    {
    	"triggers": {
    		"trackPageview": {
    			"on": "visible",
    			"request": "pageview"
    		}
    	},
    	"requests": {
    		"base": "https://www.102mg.ro/stats/matomo.php?idsite=1&rec=1&action_name=${title}&url=${sourceUrl}&rand=${random}&apiv=1&urlref=${documentReferrer}&res=${screenWidth}x${screenHeight}&lang=${browserLanguage}&gt_ms=${serverResponseTime}&cs=${documentCharset}&_cvar={"1":["errorName","${errorName}"],"2":["errorMessage","${errorMessage}"]}",
    		"pageview": "${base}"
    	}
    }
    </script></amp-analytics>

    Please help, I want to use the json code, as the normal implementation of matomo doesn’t track properly.

    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Can you please share the URL of your website once? So that we will go through the site and get back to you immediately.

    Thread Starter croif

    (@croif)

    Hello,

    My website is https://www.myblog.ro, but the code is disabled, because I get errors in Google SearchConsole.

    The code examples above are relevant, the removed backslashes from code triggers a json validation error in amp validator.

    Example: this: [\”errorMessage\”,\”${errorMessage}\”]}” gets formated like this: [“errorMessage”,”${errorMessage}”]}”

    Thank you!

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Can you please share the screengrabs of the errors of reference purposes of the issue once? So that we will go through it and get back to you immediately.

    Thread Starter croif

    (@croif)

    Hello,

    Here is the screenshot with the code added to the website:
    https://snipboard.io/qzeBcW.jpg

    The code inserted in Advance Settings > HTML in Footer:
    https://snipboard.io/KxDw6j.jpg

    The scripts on amp validator, first one validates, the output does not:
    https://snipboard.io/WqC2N9.jpg

    The thing is that I have been using this code like this for years with no problem. Suddenly the code stopped working, I guess after latest update of ampforwp.

    Thank you!

    • This reply was modified 2 years, 10 months ago by croif.
    Thread Starter croif

    (@croif)

    Sorry, wrong reply.

    • This reply was modified 2 years, 10 months ago by croif.
    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We inspected the URL but did not get any errors you mentioned. Can you please share the exact issue URL once? So that we will inspect it in the validator and get back to you immediately.

    Thread Starter croif

    (@croif)

    I told you that I can’t leave the website invalidated and provided you with all the details and the solution is that I get validation errors in google until you fix it. I provided with all the details above. You have all the code so you can check the validation by yourself and still I have to provide with what exactly?

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Ok, sorry for the inconvenience. We will inspect it again and get back to you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Validation problem for code in footer’ is closed to new replies.