Skip to content

feat: request Ads on page load#711

Merged
MatheusLealv merged 10 commits intomasterfrom
feat/use-ads-sdk
Dec 4, 2025
Merged

feat: request Ads on page load#711
MatheusLealv merged 10 commits intomasterfrom
feat/use-ads-sdk

Conversation

@rodorgas
Copy link
Copy Markdown
Contributor

@rodorgas rodorgas commented Aug 18, 2025

What problem is this solving?

This PR is part of the Ads Frictionless Integration on the Store Framework (RFC).

Use the Ads SDK to request ads instead of using the results from adserver-resolver. This allows fresh, uncached ads without compromising organic results caching.

This works by using the useAds hook from Ads SDK to retrieve ads and injecting them on props of SearchResultLayout, that contains products that must be rendered.

Also adds the sponsoredCount property to allow easily changing it from the Site Editor.

How to test it?

In this workspace, https://leal--biggy.myvtex.com/ search for the term "camisa".

Screenshots or example usage:

Sponsored products being displayed as usual when searching for product keywords of an active campaign:

image

Related to / Depends on

vtex-apps/store#605

vtex-apps/product-summary#411

@rodorgas rodorgas requested review from a team as code owners August 18, 2025 16:59
@rodorgas rodorgas requested review from gabpaladino, leo-prange-vtex and vsseixaso and removed request for a team August 18, 2025 16:59
@vtex-io-ci-cd
Copy link
Copy Markdown
Contributor

vtex-io-ci-cd bot commented Aug 18, 2025

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link
Copy Markdown

vtex-io-docs-bot bot commented Aug 18, 2025

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces integration with the VTEX Ads SDK to request fresh, uncached ads on page load instead of relying on cached results from adserver-resolver. This change allows for displaying current sponsored products while maintaining the performance benefits of organic results caching.

  • Adds @vtex/ads-react dependency and implements ads fetching using the useAds hook
  • Creates utility functions to merge sponsored products with organic search results
  • Implements loading state management to prevent UI flicker when ads are being fetched

Reviewed Changes

Copilot reviewed 7 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
react/utils/adsUtils.ts New utility function to merge sponsored products with organic search results
react/package.json Adds @vtex/ads-react dependency for ads functionality
react/hooks/useMergeResults.ts Custom hook managing the merging of ads and organic results with loading states
react/components/SearchQuery.js Removes old advertisement options from GraphQL query
react/SearchResultLayout.js Integrates ads SDK and applies merged results to layout components
react/SearchResultFlexible.js Adds sponsoredCount prop threading
manifest.json Version bump to beta for the new ads feature

vsseixaso added a commit to vtex-apps/product-summary that referenced this pull request Nov 5, 2025
#### What problem is this solving?

<!--- What is the motivation and context for this change? -->
We're changing the encoded event parameters from `adId` to
`eventParameters`, since it's not the ad ID. The data attribute is still
using the data-van-aid since that's what the Activity Flow use to track
events (to be changed in future).

This is backwards compatible as it keeps using the `adId` as fallback to
the `eventParameters` parameter.

It also removes many data properties that are not being used anymore,
since the `data-van-aid` is the only one considered by Activity Flow
currentyl

#### How to test it?

<!--- Don't forget to add a link to a Workspace where this branch is
linked -->
In this workspace, https://leal--biggy.myvtex.com/ search for the term
"camisa".



#### Screenshots or example usage:

<img width="1624" height="1060" alt="image"
src="https://github.com/user-attachments/assets/3593a558-1ac6-4cb8-859c-93fb6fea0277"
/>

<!--- Add some images or gifs to showcase changes in behaviour or
layout. Example: before and after images -->


#### Related to / Depends on

vtex-apps/store#605

vtex-apps/search-result#711

---------

Co-authored-by: Matheus Leal <matheus.leal@vtex.com>
Co-authored-by: Vinícius Seixas <vinicius.seixas@vtex.com>
@MatheusLealv MatheusLealv merged commit da70f18 into master Dec 4, 2025
10 checks passed
@MatheusLealv MatheusLealv deleted the feat/use-ads-sdk branch December 4, 2025 19:06
@vtex-io-ci-cd
Copy link
Copy Markdown
Contributor

vtex-io-ci-cd bot commented Dec 4, 2025

Your PR has been merged! App is being published. 🚀
Version 3.141.2 → 3.142.0

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy vtex.search-result@3.142.0

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

MatheusLealv added a commit that referenced this pull request Dec 8, 2025
This reverts commit da70f18, reversing
changes made to dd5a90b.
MatheusLealv added a commit that referenced this pull request Dec 8, 2025
MatheusLealv added a commit that referenced this pull request Dec 8, 2025
This reverts commit da70f18, reversing
changes made to dd5a90b.
MatheusLealv added a commit that referenced this pull request Dec 8, 2025
Revert "Merge pull request #711 from vtex-apps/feat/use-ads-sdk"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants