How to Implement Rewarded Ads on Bubble.io and Enable File Download After Ad Viewing

Hello,

I am creating a website using Bubble.io and want to allow users to download a file after viewing a rewarded ad. I am using Google AdMob for the rewarded ads and have added the following code to an HTML element, but the ads are not displaying correctly.

html

<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  var admobId = 'YOUR_ADMOB_UNIT_ID';

  function showRewardAd() {
    if (typeof admob !== 'undefined') {
      admob.rewarded.load({
        id: admobId
      }, function(error) {
        if (error) {
          console.error('Failed to load rewarded ad:', error);
          return;
        }

        admob.rewarded.show(function(reward) {
          console.log('Rewarded ad shown. Reward:', reward);
          document.getElementById('downloadLink').style.display = 'block';
        }, function(error) {
          console.error('Failed to show rewarded ad:', error);
        });
      });
    } else {
      console.error('AdMob is not initialized.');
    }
  }
</script>

<button onclick="showRewardAd()">Watch Ad to Download</button>
<a id="downloadLink" href="YOUR_FILE_URL" style="display:none;">Download File</a>

I have replaced YOUR_ADMOB_UNIT_ID with the correct ad unit ID. Can anyone help me understand what might be wrong or if there are additional settings I need to configure?

Thank you!

This topic was automatically closed after 70 days. New replies are no longer allowed.