Mobkoi Tag

This page provides an overview of the various configuration options available for the Mobkoi Tag.

Before starting the integration, ensure that all of the prerequisites have been complete,

Below is an example of the Mobkoi Tag, showcasing how it can be implemented with configurable options.

<script>
  (function (cs) {
    
    var options = {};
    
    /* DO NOT TOUCH ANYTHING BELOW */
    cs.parentNode.insertBefore(
      Object.assign(document.createElement('script'), {
        type: 'application/javascript',
        async: 1,
        src:
          `https://adserver.maximus.mobkoi.com/boot/DF2E363C?po=` +
          encodeURIComponent(JSON.stringify(options)) +
          '&cb=' +
          Math.random() +
          '&st=' +
          Date.now(),
      }),
      cs,
    );
  })(document.currentScript);
</script>

Passback Feature

The passback feature enables a fallback mechanism when an ad impression cannot be fulfilled—whether due to a lack of demand, a timeout, or an error during the ad request process. By specifying a passback script URL, the render library will automatically inject and execute the script in the event of a failure, ensuring that the ad slot doesn’t remain empty.

This fallback is commonly used to:

  • Load alternative demand sources

  • Trigger house ads or direct-sold campaigns

  • Maintain visual continuity on the page

  • Preserve monetisation opportunities

The passback script is executed client-side and only injected into the DOM if a failure condition is detected.

How It Works

  • Define a Passback URL Provide a publicly hosted HTTPS URL pointing to a JavaScript file. This script will be executed if the primary ad request fails or returns no content.

  • Automatic Script Injection If a failure is detected, the render library dynamically injects the passback script into the page, appending a targetId query parameter corresponding to the ad container's DOM ID.

  • Execution Context The script is executed in the context of the ad slot and should be responsible for rendering fallback content within the provided targetId.

  • Publisher Responsibility Publishers must ensure the script is:

    • Hosted over HTTPS

    • Self-contained (no external dependencies unless bundled)

    • Implemented to handle DOM injection using the targetId parameter

Example 1: Simple House Ad Fallback

The following example script identifies the target container and injects a simple styled fallback banner:

// Get the current script and extract the "targetId" from its query parameters
const  script = document.currentScript;
const  targetId = new  URL(script.src).searchParams.get('targetId');

if (targetId) {

	// Find the target element on the page by its ID
	const  targetElement = document.getElementById(targetId);

	// Create a basic banner
	const  banner = document.createElement('div');

	banner.style = `
	width: 100%;
	height: 250px;
	background-color: #f4f4f4;
	border: 2px solid #ccc;
	display: flex;
	justify-content: center;
	align-items: center;
	font-family: Arial, sans-serif;
	color: #333;
	font-size: 18px;
	font-weight: bold;
	text-align: center;
	`;
	banner.innerText = 'Passback House Banner';

	// Add the banner to the target element
	targetElement.appendChild(banner);
}

Example 2: GPT-Based Passback

This example dynamically loads Google Publisher Tags (GPT) and defines an ad slot using the targetId parameter:


const  script = document.currentScript;
const  url = new  URL(script.src);
const  targetId = url.searchParams.get('targetId');
 

if (!targetId) {
  console.error('targetId not specified or invalid.');
  return;
}

  
const  gptScript = document.createElement('script');
gptScript.src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js';
gptScript.crossOrigin = 'anonymous';
gptScript.async = true;
document.head.appendChild(gptScript);
  

gptScript.onload = function () {
  window.googletag = window.googletag || { cmd: [] };

  googletag.cmd.push(function () {
    googletag
    .defineSlot('/YOURNETWORK/Travel/Europe', [400, 400], targetId)
    .addService(googletag.pubads());
  
    googletag.enableServices();  
    googletag.display(targetId);
  });

};

Enabling Passback in the Render Library

To activate the passback feature, configure your render call with a passback option specifying the script URL. You may also enable passbackTest mode for development.

var options = {
	passback: '/passback.js', // URL of the passback script
	passbackTest: 1, // Enable passback testing
};

Testing the Passback Feature

To verify that the passback logic is working correctly, you can enable passback testing mode within your render library’s configuration. This forces a simulated no-fill condition and triggers the passback flow, even if an ad would normally be served.

What to Expect

When test mode is active or a genuine no-fill occurs, you should observe the following in the browser:

1. Injected Script Tag

An additional <script> tag will appear in the DOM, dynamically inserted by the render library:

<script src="https://cdn.example.com/passback.js?targetId=ad-slot-1"></script>

2. Passback Content Rendered

Depending on your script’s logic, you should see fallback content rendered inside the target container. For example:

<div id="ad-slot-1"> <div style="width:100%; height:250px; background:#f4f4f4; ..."> Passback House Banner </div> </div>

Or, in the case of GPT-based fallback, a live ad may load inside the container.


Debugging Tips

  • Check Network Tab Verify that the passback script is successfully requested. If it fails to load, ensure the script is hosted on a secure (HTTPS) and accessible domain.

  • Inspect the Script Tag Ensure the targetId query parameter is present and matches an existing DOM element.

  • Open the Console Look for any JavaScript errors during script execution. For example, missing targetId, invalid GPT configuration, or cross-origin issues.

  • Disable Test Mode for Production Remember to remove or set passbackTest: 0 before going live to ensure the fallback only triggers when necessary.


Last updated