Skip to content

Instantly share code, notes, and snippets.

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 MohammedKaludi/dc4f140412f7cb6b1f8b73c064d0e55c to your computer and use it in GitHub Desktop.
Save MohammedKaludi/dc4f140412f7cb6b1f8b73c064d0e55c to your computer and use it in GitHub Desktop.
Add Clicky Analytics to AMP
<?php
// Remove all the existing analytics code
add_action('init','ampforwp_remove_existing_analytics');
function ampforwp_remove_existing_analytics() {
remove_action('amp_post_template_footer','ampforwp_analytics',11);
}
// Build the markup for Clicky Analytics code
function ampforwp_clicky_analytics() { ?>
<amp-analytics type="clicky">
<script type="application/json">
{
"vars": {
"site_id": "YOUR_SITE_ID_HERE"
}
}
</script>
</amp-analytics>
<?php
}
// Hook / add clicky ads code into AMP pages
add_action('init','ampforwp_add_clicky_analytics_hook');
function ampforwp_add_clicky_analytics_hook() {
add_action('amp_post_template_footer','ampforwp_clicky_analytics',11);
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment