Expand my Community achievements bar.

Homework Assignment #3 Enterprise Permissions, Events, Performance Testing

Avatar

Level 4

Enterprise Permissions & Properties

In order to support enterprise permissions and properties, we need to take into consideration property tokens (at_property). In on-device decisioning, we always generate an artifact with all of activities that can be executed with on-device decisioning. Instead of generating an artifact with all activities across your org and workspaces, we can now generate an artifact per property token (at_property) so that we can ensure that the activities that are executed are for the right properties. There are 2 ways you can handle property tokens:

 

Global Property Token

If you want all getOffers calls to use the same propertyToken, you can specify a propertyToken on the config object passed in during initialization. When configured in this way all getOffers calls will automatically include the property token. When specifying the propertyToken during initialization, we will ensure to download the artifact with activities that are associated with the provided global property token.

<!DOCTYPE html>

<html lang="en">

    <head>

        <script type="text/javascript">

            window.targetGlobalSettings = {

                clientCode: "acmeclient",

                imsOrgId: "1234567890@AdobeOrg",

            };

 

            window.targetPageParams = () => ({

              at_property: "8c4630b1-16db-e2fc-3391-8b3d81436cfb"

            });

        </script>

        <script type="text/javascript" src="at.js"></script>

    </head>

    <body>

        <h1>Welcome to my website...</h1>

 

        <script type="text/javascript">

            //this call automatically gets the property specified above in targetPageParams.at_property

            adobe.target.getOffers({

                request: {

                    execute: {

                        mboxes: [{

                            name: "demo-marketing-offer1",

                            index: 0

                        }]

                    }

                }

            }).then(function (targetResponse) {

                //do something with the target response

            });

        </script>

    </body>

</html>

Incidental Property Token in getOffers Call

 

A property token can also be specified in an individual getOffers call. This is done by adding a property object with token to the request. A property token specified in this way takes precedent over one set in targetPageParams. If you are using on-device decisioning, remember that a property-specific artifact will be loaded if a token is specified in targetPageParams.at_property. So beware of a case where you specify "property-token-A" in targetPageParams, and then in a subsequent call to getOffers, override it with "property-token-B". In that case, the experiences for "property-token-B" may not be available and a warning will be logged. If you intend to make many getOffers calls with varying property token values, do not to add a property token to targetPageParams. That way you can ensure the appropriate experiences are considered regardless of decisioning method.

 

<!DOCTYPE html>

<html lang="en">

    <head>

        <script type="text/javascript">

            window.targetGlobalSettings = {

                clientCode: "acmeclient",

                imsOrgId: "1234567890@AdobeOrg",

            };

        </script>

        <script type="text/javascript" src="at.js"></script>

    </head>

    <body>

        <h1>Welcome to my website...</h1>

 

        <script type="text/javascript">

            adobe.target.getOffers({

                request: {

                    execute: {

                        mboxes: [{

                            name: "demo-marketing-offer1",

                            index: 0

                        }]

                    },

                    property: {

                        token: "8c4630b1-16db-e2fc-3391-8b3d81436cfb"

                    }

                }

            }).then(function (targetResponse) {

                //do something with the target response

            });

        </script>

    </body>

</html>

 

Read more about enterprise permissions support

 

Try it out!

  1. Download and deploy on your website the latest version of at.js
  2. Choose and implement the approach to adding the property token. Either via the global property token or via passing in the property token to each getOffers() call.
  3. Create and activate on-device decisioning AB activities for the corresponding workspace and properties that you want to test. Note: Make sure to wait at least 5 minutes after you activate your AB activities so our backend processes can generate and deploy the artifact.
  4. Verify that you can execute the AB activities for your webpage given a property and workspace that you want to test out.

 

Feedback

  1. Is on-device decisioning support for enterprise permissions via properties and workspaces designed to support your business use cases? If not, please give us use cases that this current support doesn't help you execute your business use cases.

 

New Events

There are several new events that may be of interest to you when using on-device decisioning mode. If you are not familiar with how to subscribe to at.js events, you can read more about it here.

Two new events have been added. When the callback function is called, an event object is passed in. Each event has a type corresponding to the event name. And some events include additional properties with pertinent information.

Event Description Additional Event Properties

ARTIFACT_DOWNLOAD_SUCCEEDED

Emitted each time a new artifact is downloaded.

artifactPayload, artifactLocation

ARTIFACT_DOWNLOAD_FAILED

Emitted each time an artifact fails to download.

artifactLocation, error

Usage

document.addEventListener(adobe.target.event.ARTIFACT_DOWNLOAD_SUCCEEDED, function(event) {

    const { detail } = event;

    console.log(`The on-device decisioning artifact was successfully downloaded from '${detail.artifactLocation}'`);

    // optionally do something with detail.artifactPayload

});

 

document.addEventListener(adobe.target.event.ARTIFACT_DOWNLOAD_FAILED, function(event) {

    const { detail } = event;

    console.log(`The on-device decisioning artifact failed to download from '${detail.artifactLocation}' with the following error message: ${detail.error.message}`);

 

});

These events are useful especially in the case that the artifact download has failed. You can subscribe to this failed event and make a getOffers() call with decisioningMethod = server-side to make sure that you retrieve an experience in the case that on-device decisioning fails.

 

Read more about the newly added events support for on-device decisioning.

 

Try it out!

  1. Download and deploy on your website the latest version of at.js
  2. Subscribe to the newly added events, ARTIFACT_DOWNLOAD_SUCCEEDED and ARTIFACT_DOWNLOAD_FAILED. When ARTIFACT_DOWNLOAD_FAILED try making a getOffers() call with decisioningMethod = server-side to retrieve the AB activities you are wanting to test that qualify for on-device decisioning.

 

Feedback

  1. Is the documentation straight forward? Are there other details that are not mentioned that will help you understand how these events work?
  2. Are there any other events that you would like implemented?

 

Performance Testing

In terms of performance testing, there are several tools you can use:

 

  1. Web Page Test - Gives a nice waterfall view of the performance of your page. I like this tool the best - https://www.webpagetest.org/ One the test is complete, you can Export HTTP Archive (.har)
  2. Google Chrome Developer Tool Network - Make sure to check the Preserver Log checkbox and Export HAR to download the logs.
  3. Lighthouse - Install the Lighthouse Google Chrome and generate a report for the page you are measuring performance - https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk/related
  4. Page Speed Insights https://developers.google.com/speed/pagespeed/insights


Lighthouse and Page Speed Insights tests will be useful for your production environment to see how well your pages are performing. However, for this test, the Web Page Test tool would be the most comprehensive so we can calculate how long it takes for Target to come back with the decision. Save the .har files for each test for each At.js version.

 

I would test 2 different use cases for both versions (current production version vs. on-device decisioning-enabled) of At.js.

  1. New user and first-ever page hit (make sure to clear your cookies and cache for each test)
  2. Returning user navigating to the same page
0 Replies