amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Error when trying to track amp adsense ad visibility with amp analytics and using data variable(s)

Open thesved opened this issue 9 years ago • 7 comments

I would like to track with amp analytics when an adsense ad is seen. To be able to do this I added a data var for amp-ad:

<amp-ad data-vars-event-category="list1" layout="fixed-height" height=100 type="adsense" data-ad-client="..." data-ad-slot="...">

And I got this error message:

Unknown attribute for adsense: varsEventCategory

thesved avatar Apr 20 '17 01:04 thesved

You will need to create a dedicated amp-analytics element for this and place a unique identifier on the amp-ad element. Something like the following though I'm not sure if visiblePercentageMin 0 is more correct:

`<amp-ad id='adsenseAd1' ....>

`

keithwrightbos avatar Apr 20 '17 17:04 keithwrightbos

Closing with https://github.com/ampproject/amphtml/issues/8852#issuecomment-295826775.

jridgewell avatar Apr 20 '17 22:04 jridgewell

@keithwrightbos you are right, actually there is no need to add a separate analytics tag, it can be done with an existing analytics by adding a dedicated trigger AND a dedicated request.

The request would be totally unnecessary when the data-var attributes were working for amp-ad elements (assuming I am using data-vars for what they are intended for: creating one request for multiple items and inserting variable from the items' data variables).

Now my real concern is, that there is a feature (data-var attributes) which really should work for the amp-ad element as well, like it does work for other amp elements.

thesved avatar Apr 21 '17 09:04 thesved

@jridgewell can you please reopen the issue? Or should I open a new issue?

thesved avatar Apr 30 '17 13:04 thesved

Is there an unresolved question on whether there's support for data-var attributes for amp-ad, or is that confirmed to be the case? I know this got added for supporting click events, so maybe they're only supported on <a> tags right now?

rudygalfi avatar May 01 '17 19:05 rudygalfi

@rudygalfi: it appears there is no support for data-var attributes for amp-ad, since I get the following error when I try to do it Unknown attribute for adsense: varsEventCategory

The support is not bound to a tags, it is defined here: https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md

In an ideal world amp-ad tags should support data-var attributes like any other element.

thesved avatar May 02 '17 12:05 thesved

@rudygalfi This issue is that we have a conflict between <amp-ad> data-* var gathering (which it uses to create the ad iframe), and <amp-analytics> data-var-* var gathering (which is uses for URL manipulations).

Since none of the ad tags currently depend on any data-var-* to set themselves up (they'd have to declare it in their AMP ad code), we should probably just not pass those vars to the ad.

jridgewell avatar May 02 '17 18:05 jridgewell