0

I have been recently asked to disable the additional Pageview event on Page nestet within an AMP-IFRAME. The problem is, that both pages use the Google Analytics functions which is required so far, but sending 2 Pageviews at once does not seem to be right approach, even if there are actually two diffrent Pages with diffrent domains.

So the question is:

is there an possiblity to disable the pageview event to be fired when loading the amp-iframe content?

PS. All other events should be fired as well...

Christian Felix
  • 644
  • 1
  • 9
  • 28
  • So to do this, I would think you'd need logic on the page to trigger the GA pageview events ONLY if it isn't being loaded in an iframe. So your next thing to find out is if you can detect using JS if a page is loaded through an iframe. https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t – XTOTHEL Nov 22 '18 at 15:29
  • thank you @XTOTHEL,i will give it a try. – Christian Felix Nov 22 '18 at 15:45

1 Answers1

1

You can pass a flag to the embedded page via a query parameter.

<amp-iframe src="https://example.com/amp.html?embedded=true" ...> ...</amp-iframe>

You can then change the amp-analytics code in your backend to not render the page view trigger in the page.

Another option is to dynamically load the amp-analytics configuration and pass the embedded flag via variable substitution.

<amp-analytics config="https://example.com/analytics.account.config.json?${queryParam(embedded)}">

https://example.com/analytics.account.config.json should then return different configurations based on whether embedded is true or false.

Sebastian Benz
  • 4,238
  • 1
  • 21
  • 17