Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aps integration with regards to size mismatch #140

Merged
merged 4 commits into from
Aug 28, 2024

Conversation

Trav84
Copy link
Contributor

@Trav84 Trav84 commented Aug 22, 2024

Description

The current APS integration does not work correctly if using the GAM size mapping feature. This is because while GAM accepts the size mapping feature, and will request the designated sizes at the designated breakpoints, the current APS integration simply uses the size array of the unit, which includes all potential sizes of the unit.

You can see this where the apsSlot is defined in the defineSlots() function.

This can result in a request for a size that the unit is not currently set up to display. For example a leaderboard unit may be a 320x100 on mobile, a 728x90 on tablet, and a 970x250 on desktop. All of the sizes exist in the "size" array of the unit. That unit may also contain a GAM size mapping definition that states that the 320x100 can only be requested on mobile, 728x90 on tablet, and a 970x250 on desktop.

The APS call, however, will simply include all 3 of those sizes for every request. This can cause breakage on the site as the creative delivered will likely be larger than the size of the ad unit / placeholder. This will also hurt viewability metrics (a 728x90 on mobile won't be fully viewable, etc).

Amazon has a newer method of integration called "simplerGPT" which does utilize GAM size mapping definitions. In fact you do not need to define any slot for APS, it will just use the GPT definition.

You can read about this method here.

I added a simple check for the presence of "simplerGPT" in the config that if present, will utilize the gpt slot definition for the APS calls, instead of the APS unit that is defined. I've defaulted to the older method to avoid any breakage.

Testing this I'm able to verify that APS is being called for the correct sizes at the configured breakpoints, versus the older method which requests all listed sizes.

Travis Czerw added 3 commits August 13, 2024 10:12
…size mapping is respected. Also place check on display call for GAM to prevent calling display on ads that are not rendered in the DOM
@Trav84 Trav84 requested a review from a team as a code owner August 22, 2024 21:30
@Trav84 Trav84 requested review from masonbraun and thedaviddias and removed request for a team August 22, 2024 21:30
Copy link
Contributor

@caffeinated-pixels caffeinated-pixels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution, thanks for spotting and fixing this. I've verified locally and it works.

@caffeinated-pixels caffeinated-pixels changed the title Fix APS Integration with regards to size mismatch fix: aps integration with regards to size mismatch Aug 28, 2024
@caffeinated-pixels
Copy link
Contributor

@Trav84 The changes have broken two of the unit tests. Are you able to fix?

@Trav84
Copy link
Contributor Author

Trav84 commented Aug 28, 2024

Hey @caffeinated-pixels I pushed a fix. Sorry about that! There was a missing reference to "this" in the call to get the apsSlotType which was erroring out.

Resolved and tested locally and also ran tests locally and they seem happy.

@caffeinated-pixels caffeinated-pixels merged commit 0bb7284 into KijijiCA:master Aug 28, 2024
1 check passed
thedaviddias pushed a commit that referenced this pull request Aug 28, 2024
## [4.2.14](v4.2.13...v4.2.14) (2024-08-28)

### Bug Fixes

* aps integration with regards to size mismatch ([#140](#140)) ([0bb7284](0bb7284))
@thedaviddias
Copy link
Member

🎉 This PR is included in version 4.2.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants