diff --git a/extensions/amp-story-auto-ads/0.1/story-ad-page.js b/extensions/amp-story-auto-ads/0.1/story-ad-page.js index 17be6e4cf0960..f393ddeebee5a 100644 --- a/extensions/amp-story-auto-ads/0.1/story-ad-page.js +++ b/extensions/amp-story-auto-ads/0.1/story-ad-page.js @@ -2,6 +2,7 @@ import {CommonSignals_Enum} from '#core/constants/common-signals'; import { createElementWithAttributes, isJsonScriptTag, + iterateCursor, toggleAttribute, } from '#core/dom'; import {elementByTag} from '#core/dom/query'; @@ -265,13 +266,24 @@ export class StoryAdPage { this.localizationService_ ) || uiMetadata[A4AVarNames.CTA_TYPE]; - // Store the cta-type as an accesible var for any further pings. - this.analytics_.then((analytics) => + this.analytics_.then((analytics) => { + // Store the cta-type as an accesible var for any further pings. analytics.setVar( this.index_, // adIndex AnalyticsVars.CTA_TYPE, uiMetadata[A4AVarNames.CTA_TYPE] - ) + ); + + // Set meta tag based variables. + const metaTags = (this.adDoc_ ?? this.adElement_).querySelectorAll('meta[name]'); + iterateCursor(metaTags, (tag) => { + const {content, name} = tag; + // If the meta tag name is not alphanumberical, we would ignore it. + if (/^[a-zA-Z0-9\-_]+$/.test(name)) { + analytics.setVar(this.index_, `METATAG_AD_${name}`, content); + } + }); + } ); if (