Created
February 24, 2016 23:32
-
-
Save kjy112/e8ff355d272e10396785 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
<?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