self-hostingaccelerated-mobile-pageprebid.jsamp-ad

How to make self hosted prebid server work with AMP?


The github repo does not mention any thing on how to use the self hosted server work with AMP . They have given an endpoint to access after storing the request in the server:

/openrtb2/amp?tag_id={ID} //id is the file name of request stored.

I do get the empty targeting response(since server is on local setup).But how will this data reach the amp page? where should this endpoint be requested? I read in AMP docs that user generated js doesn't work in AMP. I also setup rtc config on amp ad tag and adding vendor as per vendor config(callout-vendor.js)which sends request to the bidder's prebid server url. For example:

If i add appnexus in rtc-config vendors, the request is getting sent to:

https://prebid.adnxs.com/pbs/v1/openrtb2/amp?tag_id={id of tag}

How do i make the request to go to self hosted prebid server url


Solution

  • ok, figured this thing out..

    Doc reference: https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-publisher-implementation-guide.md#setting-up-rtc-config

    So, first we make an amp-ad tag wherein we have rtc-config attribute. Since, we are using our own server, we'll need to add it in url property as mentioned in that example in doc.

    <amp-ad width="320" height="50"
            type="network-foo"
            data-slot="/1234/5678"
            rtc-config={"urls":["our-server-url"]}>
    </amp-ad>
    

    The targeting data returned by server will be fetched by amp-ad tag and will be appended to adserver request.

    Additionally, we can make a pull request to amphtml repo on github to add our server url in callout-vendor.js file

    file reference: https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/0.1/callout-vendors.js

    Then, the amp-ad tag will look like this:

    <amp-ad width="320" height="50"
            type="network-foo"
            data-slot="/1234/5678"
            rtc-config={"vendors": {"serverAliasAsSetInCalloutVendorFile": {"MACRO1": "MacroValue"}}>
    </amp-ad>