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

Bid won message get trigger multi times if native template has multi <a> tag #102

Closed
wqi1972 opened this issue Apr 28, 2020 · 1 comment
Closed

Comments

@wqi1972
Copy link
Contributor

wqi1972 commented Apr 28, 2020

Describe the bug
If native template has multi click links, then message: "Prebid Native" will get fired multi times, and it ends up bidWon event get fired multi times.

To Reproduce
Suppose there is a native template having following html:

<a href="%%CLICK_URL_UNESC%%%%PATTERN:hb_native_linkurl%%" target="_blank" class="pb-click" pbAdId="%%PATTERN:hb_adid%%">%%PATTERN:hb_native_title%%</a>
<img src="%%PATTERN:hb_native_image%%" />
<a href="%%CLICK_URL_UNESC%%%%PATTERN:hb_native_linkurl%%" target="_blank" class="pb-click" pbAdId="%%PATTERN:hb_adid%%"><img src="%%PATTERN:hb_native_icon%%"></a>

both title and icon both are clickable.
With such html, the issue will happen.

Reason:
code fire native ad impression are:

  function loadImpTrackers(adElements) {
      for(var i = 0; i < adElements.length; i++){
          let adId = readAdIdFromSingleElement(adElements[i]);
          fireTracker(adId, 'impression');
      }
  }

      if (adElements.length > 0) {
        loadImpTrackers(adElements);
      }

So the impression tracker get triggered for each <a> with pb-click class.

Suggest solution:
change loadImpTrackers so it only fires impress tracker for first element.

@wqi1972 wqi1972 changed the title Bid won message get trigger multi times if native template has multi <a> tag Bid won message get trigger multi times if native template has multi <a> tag Apr 28, 2020
@wqi1972
Copy link
Contributor Author

wqi1972 commented May 27, 2020

Since improvements from prebid/Prebid.js#5149 is coming, this is no need anymore.

@wqi1972 wqi1972 closed this as completed May 27, 2020
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

No branches or pull requests

1 participant