# wp-parsely/3.20.2/src/Integrations/class-google-web-stories.php

Parse.ly, version 3.20.2. 56 lines.

- Page: https://pluginprobe.com/plugins/wp-parsely/3.20.2/code/src/Integrations/class-google-web-stories.php
- Raw: https://pluginprobe.com/plugins/wp-parsely/3.20.2/raw/src/Integrations/class-google-web-stories.php
- Modified: 2023-11-13T15:14:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-parsely/3.20.2/code/src/Integrations/class-google-web-stories.php#L10-L20`.

```php
<?php
/**
 * Integrations: Google Web Stories integration class
 *
 * @package Parsely
 * @since   3.2.0
 */

declare(strict_types=1);

namespace Parsely\Integrations;

/**
 * Integrates Parse.ly tracking with the Google Web Stories plugin.
 *
 * @since 3.2.0
 */
final class Google_Web_Stories extends Integration {
	/**
	 * Applies the hooks that integrate the plugin or theme with the Parse.ly
	 * plugin.
	 *
	 * @since 3.2.0
	 */
	public function integrate(): void {
		if ( defined( 'WEBSTORIES_PLUGIN_FILE' ) ) {
			add_action( 'web_stories_print_analytics', array( $this, 'render_amp_analytics_tracker' ) );
		}
	}

	/**
	 * Loads additional JavaScript for Google's Web Stories WordPress plugin.
	 * This relies on the `amp-analytics` element.
	 *
	 * @since 3.2.0
	 *
	 * @see https://docs.parse.ly/google-amp/
	 */
	public function render_amp_analytics_tracker(): void {
		$json = Amp::construct_amp_json();
		if ( strlen( $json ) > 0 ) {
			?>
			<amp-analytics type="parsely">
				<script type="application/json">
					<?php
					// Output contains the Site ID, and it's already escaped in the construct_amp_json function.
					// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
					echo $json;
					?>
				</script>
			</amp-analytics>
			<?php
		}
	}
}

```
