AMP FAQ

Google has started the AMP (Accelerated Mobile Pages) initiative to help clients optimize web page loads on mobile devices.  Salesforce DMP tagging on these AMP pages work a little differently than how we're used to seeing it on standard desktop pages.  The below FAQ will handle some of the common tasks we handle for AMP as well as some troubleshooting scenarios we have encountered so far.


What is AMP?
AMP stands for ‘Accelerated Mobile Pages’ and is designed to facilitate mobile-optimized content. A notable aspect of the design is that it keeps 3rd party JavaScript out as much as possible to improve performance, however, there are AMP libraries available to provide additional rich content.

How does the AMP library get embedded on the page?
This script enables the AMP plug-in for the page.  It needs to be placed in the <head> portion of the page to load: 

<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

How does a Salesforce DMP tag fire on an AMP page?
Each client should get a unique conf ID (represented as SAMPLE in the below code block) for their set of AMP pages.  This will be used in a custom Salesforce DMP tag they have to call: 

<amp-analytics type="krux" config="https://cdn.krxd.net/controltag/amp/SAMPLE.json"> 

How are attributes collected on an AMP page?
We can't write DTC here because AMP forbids JavaScript from running on the page to ensure optimal loads times on mobile pages. 

Instead, clients must fire a JSON snippet just after the above JSON call containing an "extraUrlParams" property.  Its intention is to specify the user and page attributes needed to append to the query string of the pixel.gif call.

Page attributes are designated with the "page." prefix.  User attributes are designated with the "user." prefix.  Multiple values for the same attribute are passed comma-delimited.  Example below: 

<script type="application/json">

{

  "extraUrlParams": {

    "user.status": "developer",

    "page.keywords": "amp, mobile, examples"

  }

}

</script>

Clients can add as many attributes as they want to "extraUrlParams" as long as they are conforming to JSON standards (JSON Lint is a good tool to validate if the client set up the JSON correctly on the page).

How do we confirm that the pixel is firing properly?
Very similar to how we confirm pixel.gif fires on a desktop page.  Use your favorite debugger (Chrome console, Firebug, Charles) to search for pixel.gif and confirm the conf ID and attributes are being sent.

How does AMP serve ads?
Ads are served through an <amp-ad> element on the page.  It loads the ad through an Iframe of a different origin and executes our JavaScript into the Iframe.  The origin point is up to the client, but it will eventually load a remote.html file provided by Salesforce.

How does a client get started with getting Salesforce DMP implemented in here?
They obtain the remote.html file from https://cdn.krxd.net/amp/v1/remote.html.  They will then upload the file to a 3rd party Iframe on their AMP page
 

EXAMPLE:

<meta name="amp-3p-iframe-src" content="https://assets.your-domain.com/path/to/remote.html"> 

They will then need to make sure the appropriate Salesforce DMP conf ID is placed in the "draw3p" method. 

For example, this is what it looks like currently in remote.html:

draw3p(Krux.amp.withConfid('abc123').interchange().draw3p());

"abc123" is the conf ID in this example.  If the conf iD is "H21u32", then the code will now look like:

draw3p(Krux.amp.withConfid('H21u32').interchange().draw3p());

What if the client wants to implement their own custom remote.html file in <amp-ad> rather than our own?
This is fine, but they will need to make some changes to ensure Salesforce DMP is supported in the ad call being made:

  1. Add the following code towards the end of the </head> tag
<script src="https://cdn.krxd.net/amp/remote.min.js"></script>

      2.  Make sure the draw3p method above is implemented in the body of
remote.html with the proper conf ID.

How does the KUID and segments get passed to DFP ad calls on AMP?
The draw3p method allows for additional optional parameters to be set.  The ones we can use to pass segments are as followed:

withNameSpace(ns) → If the account is namespaced, you will want to make sure "ns" is replaced with a string containing the namespace value.

withUserParam("kuid") → the name of the DFP targeting parameter that will be passed the KUID

withSegmentsParam("ksg") → the name of the DFP targeting parameter that will be passed the Salesforce DMP segments (comma-delimited if multiple)


EXAMPLE:

draw3p(Krux.amp

  .withConfid("SAMPLE")

  .withNamespace("myns")

  .withUserParam("kuid")

  .withSegmentsParam("ksg")

  .interchange()

  .call(function(config, done) {

     // This is just an example, don’t do this in production.

     console.debug("Callback called!", config);

     done(config);

   }

).draw3p());

How does the KUID and segments get from local storage to the ad calls if we cannot fire the JS version of the Control Tag?
By default, we do not trigger the user data service when the Salesforce DMP tag fires on an AMP page.  This is to ensure optimal performance on page load.  In these cases, only when a user has been given a KUID and segments in local storage from visiting non-AMP pages of the client's will you see that KUID and segment IDs transfer over to the DFP ad calls.

If the client does want the latest segment IDs to show up in local storage on AMP pages, they can pass the "loadUserData" method to the draw3p method to allow for that.  Using the example above, it would look like this:

draw3p(Krux.amp

  .withConfid("SAMPLE")

  .withNamespace("myns")

  .withUserParam("kuid")

  .withSegmentsParam("ksg")

  .interchange()

  .loadUserData()

  .call(function(config, done) {

     // This is just an example, don’t do this in production.

     console.debug("Callback called!", config);

     done(config);

   }

).draw3p());

I see a "[AmpAnalytics.Transport]" "Failed to send image request" error appear in my console logs pointing to beacon.krxd.net/pixel.gif.  How do we troubleshoot it?
This is a known issue with AMP.  It has nothing to do with Salesforce DMP and we will still be able to collect data.  

AMP requires an image to return for transmitting analytics to it.  Since we always return a 204 response in pixel.gif, the error is always bound to happen.

See more details on https://github.com/ampproject/amphtml/issues/2342.


A client pulls a DFP report and sees impressions on some DFP ad units using "ksg" segments on AMP pages, but not all.  Why is not more data coming in on these AMP sections?
Remember that user data service is not turned on by default on Salesforce DMP-tagged AMP pages.  If not enabled, then the segments passing to the ad calls will only be what is already in local storage already for the user based on their activity on the client's other non-AMP pages.

Also remember that there is a performance impact when user data service is turned on - clients will need to take that into consideration if getting more activity on segments is important.

 
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.