Amp-wp: Add support for Google AMP Client ID API

Created on 6 Sep 2017  路  8Comments  路  Source: ampproject/amp-wp

Most helpful comment

I suggest we reveal a checkbox to opt-in to client ID specifically when googleanalytics is specified as the Type.

All 8 comments

This is what the plugin currently provides for analytics entries.

image

What we could do is if a user supplies googleanalytics as the type, that an additional checkbox appears to opt-in to client ID.

Really it would be ideal if this was all done automatically based on the script sanitizer described in #1032. For example, if the script sanitizer came across a script like:

<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXXX-Y', 'auto', {'useAmpClientId': true});
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->

Then it should automatically convert this into:

<meta name="amp-google-client-id-api" content="googleanalytics">
<script src="https://cdn.ampproject.org/v0/amp-analytics-latest.js" async="" custom-element="amp-analytics"></script>
...
<amp-analytics id="f27ffc1d4690" type="googleanalytics">
<script type="application/json">
{
    "triggers": {
        "trackPageview": {
            "on": "visible",
            "request": "pageview"
        }
    },
    "vars": {
        "account": "UA-XXXXX-Y"
    }
}
</script>
</amp-analytics>

Reopening this issue to add option to admin panel.

I suggest we reveal a checkbox to opt-in to client ID specifically when googleanalytics is specified as the Type.

Is it possible to activate the client ID option in Wordpress somehow right now?

@westonruter @nekromoff @christianoliveira The Google Site Kit plugin supports AMP client ID on both sides, covering the non-AMP part as well as the AMP part.

Awesome. I think we're done here then. The next step is to soft-deprecate the Analytics admin screen by encouraging users to install one of the AMP-compatible ecosystem plugins that tailor the given analytics product to their site. See #2317.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luizeof picture luizeof  路  4Comments

westonruter picture westonruter  路  5Comments

swissspidy picture swissspidy  路  4Comments

alexhaller picture alexhaller  路  5Comments

westonruter picture westonruter  路  3Comments