简体   繁体   中英

Google Analytics on AMP page not reporting traffic

I'm trying to get Google Analytics to work on my AMP landing pages. I have followed this guide for how to setup the analytics on how to include it on each page.

The config looks like this

<amp-analytics type=“googleanalytics” id="main_tracking">
    <script type="application/json">
    {
        "vars": {
            "account": "UA-49671924-1"
        },
        "extraUrlParams": {
            "cd1": "{{_country}}",
            "cd2": "{{_language}}"
        },
        "triggers": {
            "trackPageview": {
                "on": "visible",
                "request": "pageview"
            },
            "trackEvent": {
                "on": "visible",
                "request": "event",
                "vars": {
                    "eventCategory": "amp",
                    "eventAction": "viewed_amp"
                }
            }
        },
        "trackClickOnHeader": {
            "on": "click",
            "selector": "#header",
            "request": "event",
            "vars": {
                "eventCategory": "ui-components",
                "eventAction": "header-click"
            }
        }
    }
    </script>
</amp-analytics>

But when I run the pages, the console returns the following errors.

[AmpAnalytics main_tracking]" "No request strings defined. Analytics data will not be sent from this page."

[AmpAnalytics main_tracking]" "Ignoring event. Request string not found: " "pageview"

[AmpAnalytics main_tracking]" "Ignoring event. Request string not found: " "event"

On the Google Analytics side, nothing seems to be recorded.

Now I can't find much about this error, if anything, but I'm assuming it refers to the requests object needed if you want to send analytics to a custom URL . But I don't understand why this is being requested when trying to run Google Analytics

Does anyone know if something is missing, and what?

It looks like you're using smart quotes here

type=“googleanalytics” 

If you remove the smart quotes and use normal quotes it should work ie like this:

type="googleanalytics"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM