🪝useReneVerse

The useReneVerse hook is your go-to for handling Smart Ad logic in Phaser 3.

These hooks enable ad serving, retrieval of ad surfaces, and ad tracking, simplifying the integration of advertising features into your projects.


📥 getAdSurfaces()

Description: Fetches all ad surfaces configured for your game in the ReneVerse Portal.

import { PhaserHooks } from "@reneverse/rene-sdk-phaser";

function App() {
  
  // Initialize PhaserHooks with API Key and Private Key for ReneVerse
  const phaserHooks = new PhaserHooks({
    apiKey: '<YOUR API KEY>',
    privateKey: '<YOUR PRIVATE KEY>',
  });
  
  const getAdSurfaces = async () => {
    // Fetch all Ad surfaces configured in your game on the ReneVerse portal
    const adSurfaces = await phaserHooks.useReneVerse().getAdSurfaces();
    
    console.log(adSurfaces);
  }
  
  // Creating a button to call the getAdSurfaces function
  return (
      <div>
        <button onClick={getAdSurfaces}>
          Get Ad Surfaces
        </button>
      </div>
  );
}

export default App;

Returns


🎯 getAd()

Description: Fetches a Smart Ad for the given ad surface.

Params

  • adSurfaceId : string

Returns


👁️ trackAdSingle()

Description: Tracks a single ad’s visibility and view time. Records impressions for served Ads.

Params

  • ad : type ServeAd — The served ad object

  • screenCoveragePercentage: number — Percentage visible

  • timeInMilliseconds: number — Time in ms the ad was visible

  • angleView?: number — Viewing angle

Returns


👀 trackAdMultiple()

Description: Aggregate and record impressions for several served ads concurrently, reducing individual tracking overhead and streamlining analytics collection.

Params

  • adDataList : [{ ad : type ServeAd screenCoveragePercentage: number timeInMilliseconds: number angleView?: number }]

Returns

Last updated