Skip to content

Instantly share code, notes, and snippets.

@swissspidy
Created April 21, 2022 16:48
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 swissspidy/5f47f301889eb39ca3888a3e1fb8afb9 to your computer and use it in GitHub Desktop.
Save swissspidy/5f47f301889eb39ca3888a3e1fb8afb9 to your computer and use it in GitHub Desktop.
Sample integration of Comscore analytics code with the Web Stories WordPress plugin.
<?php
/**
* Plugin Name: Web Stories Comscore Analytics
* Description: Sample integration of Comscore analytics code with the Web Stories WordPress plugin.
* Plugin URI: https://wp.stories.google/
* Author: Pascal Birchler, Google
* Author URI: https://opensource.google.com/
* Version: 0.0.1
* License: Apache License 2.0
* License URI: https://www.apache.org/licenses/LICENSE-2.0
*/
add_action(
'web_stories_print_analytics',
static function () {
?>
<amp-analytics type="comscore">
<script type="application/json">
{
"vars": {
"c2": "YOUR PUBLISHER ID GOES HERE"
},
"extraUrlParams": {
"comscorekw": "amp"
}
}
</script>
</amp-analytics>
<?php
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment