Last active
December 9, 2016 10:09
-
-
Save y-krn/f3ae66a753d5498af27d74f67023064f to your computer and use it in GitHub Desktop.
AMP Custom Google Analytics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'amp_post_template_analytics', function ( $analytics ) { | |
if ( ! is_array( $analytics ) ) { | |
$analytics = array(); | |
} | |
// https://developers.google.com/analytics/devguides/collection/amp-analytics/ | |
$analytics['xyz-googleanalytics'] = array( | |
'type' => 'googleanalytics', | |
'attributes' => array(), | |
'config_data' => array( | |
'vars' => array( | |
'account' => 'UA-xxxxxxxx-1', | |
), | |
'triggers' => array( | |
'trackPageview' => array( | |
'on' => 'visible', | |
'request' => 'pageview', | |
), | |
), | |
), | |
); | |
return $analytics; | |
} ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment