Skip to content

Instantly share code, notes, and snippets.

@Pseric
Last active October 2, 2016 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pseric/080d107dfbda3f5ffd3c1d3b52850b46 to your computer and use it in GitHub Desktop.
Save Pseric/080d107dfbda3f5ffd3c1d3b52850b46 to your computer and use it in GitHub Desktop.
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