Last active
July 26, 2021 08:53
-
-
Save swissspidy/3a0fce0cde54aec55b7c93e9abb26772 to your computer and use it in GitHub Desktop.
OBSOLETE: Sample integration of Google Ad Manager with the Web Stories WordPress plugin
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 | |
/** | |
* Plugin Name: Web Stories Ad Manager | |
* Description: Sample integration of Google Ad Manager 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 () { | |
// TODO: Replace with your slot ID from DFP. | |
$slot = '/123456789/a4a/amp_story_dfp_example'; | |
?> | |
<amp-story-auto-ads> | |
<script type="application/json"> | |
{ | |
"ad-attributes": { | |
"type": "doubleclick", | |
"data-slot": "<?php echo esc_js( $slot ); ?>" | |
} | |
} | |
</script> | |
</amp-story-auto-ads> | |
<?php | |
} | |
); |
@pbelushi Thanks for sharing! You might be pleased to hear that we're already working on integrating this directly into the Web Stories for WordPress plugin. See GoogleForCreators/web-stories-wp#5611. This should be available very soon.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear Pascal
I have done a adaptation of your plugin to Adsense, according instructions from https://support.google.com/adsense/answer/10175505 The php code adapted if bellow, for you use:
`<?php
/**
*/
add_action(
'web_stories_print_analytics',
static function () {
// TODO: Replace with your slot ID from DFP.
$slot = 'insert your slot';
$client = 'insert your Adsense client code '
?>
<script type="application/json">
{
"ad-attributes": {
"type": "adsense",
"data-ad-client": "",
"data-slot": ""
}
}
);`