Link Search Menu Expand Document

PDF

Passing Mobile Parameters via JavaScript Ad Tags

Publishers

Last updated on September 30, 2016


Some ad servers do not provide macros for passing certain information, such as device and location data. OpenX can help you monetize if you pass the following types of information from your app to an OpenX JavaScript tag via your ad server’s SDK:

  • Advertising ID
  • App bundle ID
  • App name
  • App store URL
  • Device ID
  • Location (latitude and longitude)

For example, you can pass parameters from custom apps by Android and iOS devices using the MoPub or DFP JavaScript tag integrations.


on this page


MoPub Mobile App Integration

Last updated on December 11, 2019

You must have an OpenX Ad Exchange for Publishers account and a MoPub account.

You can create OpenX JavaScript ad tags to integrate with MoPub and pass various parameters from custom apps on Android and iOS devices.

You can include MoPub macros in OpenX ad tags to automatically capture user-specific parameters. However, you need to manually define inventory-specific parameters.


JavaScript ad tag with MoPub macros

The following sample tag used with MoPub integrations shows a variety of parameters auto-populated with MoPub macros.

Click to expand sample
<!-- Begin OpenX Tag -->
<script type="text/javascript" src="http://DELIVERY_SERVER_DOMAIN/ma/1.0/jstag"></script>
<script type="text/javascript">
	OX.requestAd({
		"auid": "[OpenX_AdUnitID]",
		"appName": "Client App Name",
		"appBundle": "com.clientname.appname",
		"appStoreURL": "http://itunes.apple.com/us/app/app_name/ID_number",
		"ifa": "%eudid!",
		"lmt": "%%DNT%%",		
		"coords": {
			"latitude": "%%LATITUDE%%",
			"longitude": "%%LONGITUDE%%"
		},
		"openrtb": {
			"app": {
				"publisher": {
					"name": "publisher",
				},
				"storeurl": "http://itunes.apple.com/us/app/app_name/ID_number"
			}
		},
		"fallback": "<script type=\"text/javascript\" charset=\"utf-8\">loaded=true;window.location=\"mopub://failLoad\";<\/script>"
	});
</script>
<!--End OpenX Tag-->

Where:

  • src="http://DELIVERY_SERVER_DOMAIN/ma/1.0/jstag: A request by the mobile app (/ma) to fetch the OpenX JavaScript tag library.

  • auid: (Required) The OpenX ad unit ID of the ad to be retrieved.

  • appName: The display name of the mobile app.

  • appBundle: The bundle (or “package”) name of an app.

  • appStoreURL: (Required) The app store URL for the app.

  • ifa: The ID for advertisers (also known as “IDFA”) with dashes.

  • '%eudid!': A MoPub ID macro used to combine the IDFA, SHA1 Hashed Android ID, or Android Advertising ID.

  • lmt: Limit ad tracking flag. Passed if the user’s device has opted out of interest-based ads.

  • %%DNT%%: A MoPub macro for Do Not Track.

  • coords: The GPS latitude and longitude of the end user, which are mapped to the %%LATITUDE%% and %%LONGITUDE%% MoPub macros.

  • fallback: A fallback sends the request back to MoPub if OpenX does not fill the request.

Once you have constructed the tag based on your needs, you can paste it into the HTML Body field of the MoPub UI, which is in the location: Order > Line Item > Creative

See also MoPub custom network setup


DFP Mobile App Integration

Last updated on May 18, 2017

If you are using the OpenX Ad Exchange and DFP as your ad server, you can create OpenX JavaScript ad tags to integrate with DFP and pass various parameters from custom apps on Android and iOS devices.

You can include DFP macros in OpenX ad tags to automatically capture user-specific parameters. However, you need to manually define inventory-specific parameters.


Sample JavaScript ad tag with DFP macros

The following sample tag used with DFP integrations shows a variety of manually-defined parameters. The industry-standard parameters for Limit Ad Tracking (lmt) and device ID (ifa) also pass DFP macros for the user’s device identifier and Limit Ad Tracking setting, respectively.

Click to expand sample
<!-- Begin OpenX Tag -->
            <script type="text/javascript" src="https://DELIVERY_SERVER_DOMAIN/ma/1.0/jstag"></script>
            <script type="text/javascript">
                var lmt = 0%%ADVERTISING_IDENTIFIER_IS_LAT%%,
                ad = {
                "auid": "[OpenX_AdUnitID]",
                "appName": "Client App Name",
                "appBundle": "com.clientname.clientapp",
                "appStoreURL": "https://itunes.apple.com/us/app/app_name/ID_number",
                "ifa": "%%ADVERTISING_IDENTIFIER_PLAIN%%",
                "openrtb": {
                "app": {
                "publisher": {
                "name": "DFP App Tag Publisher"
                },
                "storeurl": "https://itunes.apple.com/us/app/app_name/ID_number"
                }
                }
                };
                if(lmt == 0 || lmt == 1){ad.lmt=lmt;}
                OX.requestAd(ad);
            </script>
        <!-- End OpenX Tag -->

Where:

  • src="http://DELIVERY_SERVER_DOMAIN/ma/1.0/jstag: A request by the mobile app (/ma) to fetch the OpenX JavaScript tag library.

  • lmt: The limit ad tracking flag. Passed if the user’s device has opted out of interest-based ads.

  • %%ADVERTISING_IDENTIFIER_IS_LAT%%: A DFP Device ID macro used to send the user’s Limited Ad Tracking setting.

  • auid: (Required) The OpenX ad unit ID of the ad to be retrieved.

  • appName: The display name of the mobile app.

  • appBundle: The bundle (or “package”) name of an app.

  • appStoreURL: (Required) The app store URL for the app.

  • ifa: The ID for advertisers (also known as “IDFA”) with dashes.

  • %%ADVERTISING_IDENTIFIER_PLAIN%%: A DFP Device ID macro used to combine the IDFA for iOS and AdID for Android.

  • OX.requestAd: A call to the requestAd method that invokes an ad request.

Once you have constructed the tag based on your needs, you can paste it into the HTML Body field of the DFP UI, which is in the location: Order > Line Item > Creative


Optional enhanced DFP tag

Depending on what key values you currently pass to DFP, you can use DFP macros to populate additional data. Below is an example for passing GPS latitude and longitude to DFP using custom keys lat and lon, as well as passing gender with a custom gender macro.

Click to expand sample
<!-- Synchronous tag structure; Ad Unit: $ox.ad.unit.id$ $ox.ad.unit.name$ $ox.ad.unit.width$x$ox.ad.unit.height$ -->
<!-- Begin OpenX Tag -->
            <script type="text/javascript" src="https://DELIVERY_SERVER_DOMAIN/ma/1.0/jstag"><!/script>
            <script type="text/javascript">
                var lmt = 0%%ADVERTISING_IDENTIFIER_IS_LAT%%,
                ad = {
                "auid": "[OpenX_AdUnitID]",
                "appName": "Client App Name",
                "appBundle": "com.clientname.clientapp",
                "appStoreURL": "https://itunes.apple.com/us/app/app_name/ID_number",
                "ifa": "%%ADVERTISING_IDENTIFIER_PLAIN%%",
                "coords": {
                "latitude": "%%PATTERN:lat%%",
                "longitude": "%%PATTERN:lon%%"
                },
                "openrtb": {
                "app": {
                "publisher": {
                "name": "DFP App Tag Publisher"
                },
                "storeurl": "https://itunes.apple.com/us/app/app_name/ID_number"
                },
                "user": {
                "gender": "%%PATTERN:gender%%"
                }
                }
                };
                if(lmt == 0 || lmt == 1){ad.lmt=lmt;}
                OX.requestAd(ad);
            </script>
<!-- End OpenX Tag -->

For more information on parameters that can be added to get various data, see the requestAd OX method.

The OpenRTB object allows you to pass specific additional parameters. See OpenRTB fields passed by publishers.