Skip to content

Instantly share code, notes, and snippets.

@kjy112
Created February 24, 2016 23:32
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 kjy112/e8ff355d272e10396785 to your computer and use it in GitHub Desktop.
Save kjy112/e8ff355d272e10396785 to your computer and use it in GitHub Desktop.
<?php
/*
* Adding actual Google Analytics
*/
add_action( 'amp_post_template_footer', 'xyz_amp_add_analytics' );
function xyz_amp_add_analytics() {
?>
<amp-analytics type="googleanalytics" id="analytics1">
<script type="application/json">
{
"vars": {
"account": "UA-xxxxxxxx-x" /*insert your GA tracking id*/
},
"triggers": {
"trackPageviewWithAmpdocUrl": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment