Skip to content

Commit

Permalink
Add meta tag to variable list in story ads
Browse files Browse the repository at this point in the history
  • Loading branch information
powerivq committed Jan 20, 2022
1 parent a993fd7 commit 8618f0d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions extensions/amp-story-auto-ads/0.1/story-ad-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 8618f0d

Please sign in to comment.