Last active
October 2, 2016 08:09
-
-
Save Pseric/080d107dfbda3f5ffd3c1d3b52850b46 to your computer and use it in GitHub Desktop.
This file contains 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
add_filter( 'amp_post_template_analytics', 'xyz_amp_add_custom_analytics' ); | |
function xyz_amp_add_custom_analytics( $analytics ) { | |
if ( ! is_array( $analytics ) ) { | |
$analytics = array(); | |
} | |
// https://developers.google.com/analytics/devguides/collection/amp-analytics/ | |
$analytics['xyz-googleanalytics'] = array( | |
'type' => 'googleanalytics', | |
'attributes' => array( | |
// 'data-credentials' => 'include', | |
), | |
'config_data' => array( | |
'vars' => array( | |
'account' => "UA-XXXXX-Y" | |
), | |
'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