: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
'reportSuiteId' => $ReportSuiteId
$adobe_fields = apply_filters('ampforwp-adobe-analytics', $adobe_fields);?>
<amp-analytics <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?> type="adobeanalytics">
<script type="application/json">
<?php echo wp_json_encode( $adobe_fields,JSON_UNESCAPED_SLASHES); ?>
if ( true == ampforwp_get_setting('ampforwp-Piwik-Pro-switch')) {
$ppas_host = ampforwp_get_setting('ppas-host');
$ppas_id = ampforwp_get_setting('ppas-website-id');
$ppas_hash = ampforwp_get_setting('ppas-website-hash');
$ppas_tracking = ampforwp_get_setting('ppas-advanced-tracking');
$ppas_custom_code = ampforwp_get_setting('ppas-advanced-tracking-code');
if($ppas_tracking && !empty($ppas_custom_code))
$ppas_fields = str_replace(array('##instance_domain##','##app_id##','##tracker_hash##'),array($ppas_host,$ppas_id,$ppas_hash),$ppas_custom_code);
'website_hash'=> $ppas_hash
$ppas_fields = wp_json_encode( $ppas_fields);
$ppas_fields = apply_filters('ampforwp_piwikpro_analytics', $ppas_fields );?>
<amp-analytics <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?> type="ppasanalytics">
<script type="application/json">
<?php echo $ppas_fields; ?>
if( true == ampforwp_get_setting('ampforwp-plausible-switch')) {
$site_url = site_url();?>
<script type="application/json">
"dataDomain": "<?php echo esc_attr($site_url);?>"
"event": "https://plausible.io/api/event"
if( true == ampforwp_get_setting('amp-atinternet-switch')) {
$site_id = $site_url = $title = '';
$site_id = ampforwp_get_setting('amp-atinternet-site-id');
$title = get_the_title(ampforwp_get_the_ID());
if (!empty($site_id)) {?>
<amp-analytics type="atinternet" id="atinternet">
<script type="application/json">
"site": "<?php echo esc_attr($site_id);?>",
"domain": "<?php echo esc_attr($site_url);?>",
"title": "<?php echo esc_attr($title);?>",
if(function_exists('ampforwp_get_setting') && true == ampforwp_get_setting('ampforwp-publytics-switch')) {
$title = $track_code = '';
$title = get_the_title(ampforwp_get_the_ID());
$track_code = ampforwp_get_setting('ampforwp-publytics-track-code');
if (!empty($track_code)) { ?>
<script type="application/json">
"event": "https://api.publytics.net/events"
"r": "${documentReferrer}",
"d": "<?php echo esc_attr($track_code);?>"
"article_title": "<?php echo esc_attr($title);?>"
"on":"amp-next-page-scroll",
"useInitialPageSize": true,
"n": "amp_next_page_pageview"
"on":"amp-next-page-click",
"useInitialPageSize": true,
"n": "amp_next_page_pageview"
if(true == ampforwp_get_setting('amp-marfeel-pixel')){
$account_id = ampforwp_get_setting('amp-marfeel-account-id'); ?>
<amp-analytics config="https://events.newsroom.bi/amp.v1.json" data-credentials="include">
<script type="application/json" >
"accountId": "<?php echo esc_attr($account_id);?>"
if( true == ampforwp_get_setting('ampforwp-iotech-switch')) {
$project_id = $id = $title = $author = $categories = $cat_names = '';
$project_id = ampforwp_get_setting('ampforwp-iotech-projectid');
$id = ampforwp_get_the_ID();
$title = get_the_title($id);
$author = get_the_author_meta('display_name');
$categories = get_the_terms( $id, 'category' );
foreach ($categories as $key=>$cat ) {
$cat_names .= '|' . $cat->name ;
$cat_names = substr($cat_names, 1);
$content = get_post_field( 'post_content', $id );
$word_count = str_word_count( strip_tags( $content ) );
$date = get_post_time('F d, Y g:i a');
<script type="application/json">
"pageview": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:pageviews[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
"read_top": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_top[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
"read_middle": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_middle[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
"read_bottom": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_bottom[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
"read_finished": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_finished[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
"time": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:time[platform:amp,url:${canonicalPath}]"
"page_title": "$<?php echo esc_attr($title) ?>",
"page_language": "<?php echo esc_attr($lang) ?>",
"article_authors": "<?php echo esc_attr($author) ?>",
"article_categories": "<?php echo esc_attr($cat_names) ?>",
"article_type": "longread",
"article_word_count": "<?php echo esc_attr($word_count) ?>",
"article_publication_date": "<?php echo esc_attr($date) ?>"
"verticalBoundaries": [25]
"verticalBoundaries": [50]
"verticalBoundaries": [75]
"verticalBoundaries": [90]
"request": "read_finished"
add_action('amp_post_template_footer','ampforwp_facebook_pixel',11);
function ampforwp_facebook_pixel() {
global $redux_builder_amp;
if( ampforwp_get_setting('amp-fb-pixel') ){
$amp_pixel = '<amp-pixel ';
if(ampforwp_get_data_consent()){
$amp_pixel .= 'data-block-on-consent';
$amp_pixel .= ' src="https://www.facebook.com/tr?id='.esc_attr(ampforwp_get_setting('amp-fb-pixel-id')).'&ev=PageView&noscript=1"></amp-pixel>';
echo $amp_pixel; // escaped above
// For Setting up Google AMP Client ID API
add_action( 'amp_post_template_head' , 'ampforwp_analytics_clientid_api' );
if( ! function_exists( ' ampforwp_analytics_clientid_api ' ) ) {
function ampforwp_analytics_clientid_api() {
global $redux_builder_amp;
if ( true == ampforwp_get_setting('ampforwp-ga-switch') || true == ampforwp_get_setting('amp-use-gtm-option')){ ?>
<meta name="amp-google-client-id-api" content="googleanalytics">
if ( ! function_exists('amp_activate') ) {
add_action('amp_init', 'amp_gtm_remove_analytics_code');
function amp_gtm_remove_analytics_code() {
global $redux_builder_amp;
if( isset($redux_builder_amp['amp-use-gtm-option']) && $redux_builder_amp['amp-use-gtm-option'] ) {
//Add GTM Analytics code right after the body tag
add_action('ampforwp_body_beginning','AMPforWP\\AMPVendor\\amp_post_template_add_analytics_data',10);
//Remove other analytics if GTM is enable
add_action('amp_post_template_footer','ampforwp_gtm_support', 9);
function ampforwp_gtm_support(){
global $redux_builder_amp;
if( isset($redux_builder_amp['amp-use-gtm-option']) && $redux_builder_amp['amp-use-gtm-option'] ) {
remove_action( 'amp_post_template_footer', 'AMPforWP\\AMPVendor\\amp_post_template_add_analytics_data' );
add_action( 'ampforwp_body_beginning', 'ampforwp_add_advance_gtm_fields' );
function ampforwp_add_advance_gtm_fields( $ampforwp_adv_gtm_fields ) {
if(true == ampforwp_get_setting('amp-use-gtm-option')){
$gtm_id = ampforwp_get_setting('amp-gtm-id');
$gtm_analytics = ampforwp_get_setting('amp-gtm-analytics-code');
if(true == ampforwp_get_setting('ampforwp-gtm-field-advance-switch') ){
$ampforwp_adv_gtm_fields = "";
$ampforwp_adv_gtm_fields = ampforwp_get_setting('ampforwp-gtm-field-advance');
$ampforwp_adv_gtm_fields = preg_replace('!/\*.*?\*/!s', '', $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = preg_replace('/\n\s*\n/', '', $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = preg_replace('/\/\/(.*?)\s(.*)/m', '$2', $ampforwp_adv_gtm_fields);
$id = ampforwp_get_the_ID();
$title = get_the_title($id);
$category_detail = get_the_category($id);//$post->ID
if ( ! empty( $category_detail ) ) {
foreach($category_detail as $cd){
$category_name_array[] = $cd->cat_name;
$category_name = implode( ', ', $category_name_array );
$url = get_the_permalink();
$author_id = get_post_field( 'post_author', $id );
$author_name = get_the_author_meta( 'display_name' , $author_id );
$published_at = get_the_date( 'F j, Y' , $id );
$tags = get_the_tags( $id );
foreach( $tags as $tag ) {
$tag_names[] = $tag->name;
$tagNames = implode( ', ', $tag_names );
$ampforwp_adv_gtm_fields = str_replace('{url}', $url, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{id}', $id, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{title}', $title, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{category}', $category_name, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_gtm_fields);
$ampforwp_adv_gtm_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_gtm_fields);
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>><script type="application/json"><?php echo sanitize_text_field($ampforwp_adv_gtm_fields) ?></script></amp-analytics> <?php
if($gtm_id!="" && empty($gtm_analytics)){ ?>
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>></amp-analytics> <?php
if($gtm_id!="" && !empty($gtm_analytics)){ ?>
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>data-credentials="include"><script type="application/json">{ "vars": { "account": "<?php echo esc_html($gtm_analytics);?>"} }</script></amp-analytics>
// 83. Advance Analytics(Google Analytics)
add_filter('ampforwp_advance_google_analytics','ampforwp_add_advance_ga_fields');
function ampforwp_add_advance_ga_fields($ga_fields){
global $redux_builder_amp, $post;
$url = $title = $id = $author_id = $author_name = '';
$url = get_the_permalink();
if(!is_object($post)){ return $ga_fields; }
$id = ampforwp_get_the_ID();
$title = get_the_title($id);
$category_detail = get_the_category($id);//$post->ID
if ( ! empty( $category_detail ) ) {
foreach($category_detail as $cd){
$category_name_array[] = $cd->cat_name;
$category_name = implode( ', ', $category_name_array );
$tags = get_the_tags( $id );
if( defined('WPSEO_FILE')){
$focusKeyword = get_post_meta($id, '_yoast_wpseo_focuskw', true);
$seoScore = get_post_meta($id, '_yoast_wpseo_content_score', true);
foreach( $tags as $tag ) {
$tag_names[] = $tag->name;
$tagNames = implode( ', ', $tag_names );
$author_id = get_post_field( 'post_author', $id );
$author_name = get_the_author_meta( 'display_name' , $author_id );
$published_at = get_the_date( 'F j, Y' , $id );
$ampforwp_adv_ga_fields = array();
$ampforwp_adv_ga_fields = ampforwp_get_setting('ampforwp-ga-field-advance');
if($ampforwp_adv_ga_fields) {
$ampforwp_adv_ga_fields = str_replace('{url}', $url, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{id}', $id, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{title}', $title, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{category}', $category_name, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_ga_fields);
if( defined('WPSEO_FILE')){
$ampforwp_adv_ga_fields = str_replace('{seo_score}', $seoScore, $ampforwp_adv_ga_fields);
$ampforwp_adv_ga_fields = str_replace('{focus_keyword}', $focusKeyword, $ampforwp_adv_ga_fields);
return $ampforwp_adv_ga_fields;
//Advance Analytics(Google Analytics 4)
add_filter('ampforwp_advance_google_analytics4','ampforwp_add_advance_ga4_fields');
function ampforwp_add_advance_ga4_fields($ga4_fields){
global $redux_builder_amp, $post;
$url = $title = $id = $author_id = $author_name = '';
$url = get_the_permalink();
if(!is_object($post)){ return $ga4_fields; }
$id = ampforwp_get_the_ID();
$title = get_the_title($id);
$category_detail = get_the_category($id);//$post->ID
if ( ! empty( $category_detail ) ) {
foreach($category_detail as $cd){
$category_name_array[] = $cd->cat_name;
$category_name = implode( ', ', $category_name_array );
$tags = get_the_tags( $id );
if( defined('WPSEO_FILE')){
$focusKeyword = get_post_meta($id, '_yoast_wpseo_focuskw', true);
$seoScore = get_post_meta($id, '_yoast_wpseo_content_score', true);
foreach( $tags as $tag ) {
$tag_names[] = $tag->name;
$tagNames = implode( ', ', $tag_names );
$author_id = get_post_field( 'post_author', $id );
$author_name = get_the_author_meta( 'display_name' , $author_id );
$published_at = get_the_date( 'F j, Y' , $id );
$ampforwp_adv_ga4_fields = array();
$ampforwp_adv_ga4_fields = ampforwp_get_setting('ampforwp-ga4-field-advance');
if($ampforwp_adv_ga4_fields) {
$ampforwp_adv_ga4_fields = str_replace('{url}', $url, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{id}', $id, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{title}', $title, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{category}', $category_name, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_ga4_fields);
if( defined('WPSEO_FILE')){
$ampforwp_adv_ga4_fields = str_replace('{seo_score}', $seoScore, $ampforwp_adv_ga4_fields);
$ampforwp_adv_ga4_fields = str_replace('{focus_keyword}', $focusKeyword, $ampforwp_adv_ga4_fields);
return $ampforwp_adv_ga4_fields;