Edit in GitHubLog an issue

Pass Parameters to a global mbox

The JavaScript targetPageParams function is used to pass parameters to the global mbox in Adobe Target. This is needed in any scenario where additional targeting/context information is to be passed into Target.

For example, in a Recommendations activity, use the parameters to represent the current product or category that is being viewed.

The code to call the JavaScript function must come before the global mbox on the page, whether the global mbox is fired as a part of at.js or is manually included in the page code.

You can pass in parameters to target-global-mbox using the targetPageParams() function in any of the following ways:

  • An array
  • A JSON object
  • An ampersand-delimited list

Use these three methods to verify that the parameters are being passed correctly. You might also be able to verify the passing of parameters using the Adobe Experience Cloud Debugger.

You must define the JavaScript function before adding the global mbox to the page. The name must be targetPageParams.

Query String#

Copied to your clipboard
p1=v1&p2=v2&p3=hello%20world
  • Name: targetPageParams

  • Return value: a "&" delimited parameters, with URL encoded parameter values.

    Example:

    In this example, p3 has the value hello world, which is URL encoded.

Consider the following example page code:

Copied to your clipboard
1<html>
2 <head>
3 <title>Title here..</title>
4 <script type="text/javascript">
5 function targetPageParams() {
6 return "p1=v1&p2=v2&p3=hello%20world";
7 }
8 </script>
9 <script src="mbox.js" type="text/javascript"></script>
10 </head>
11 <body>Body here...
12 </body>
13</html>

This example sends the following data to the mbox edge:

  • p1=v1
  • p2=v2
  • p3=hello world

Array#

Copied to your clipboard
1<!--window.-->targetPageParams = function() {
2 return ["a=1", "b=2", "c=hello world"];
3};
4

Values do not need to be URL encoded. For example, if a value contains a space, there is no need to encode the space.

This example sends the following data to the mbox edge:

  • a=1
  • b=2
  • c=hello world

JSON#

JSON is a powerful way to pass parameters. Target uses the JSON object keys to flatten complicated structures into simple parameters.

Copied to your clipboard
1<!--window.-->targetPageParams = function() {
2 return {
3 "a": 1,
4 "b": 2,
5 "profile": {
6 "memberStatus": Gold,
7 "country": {
8 "city": "San Francisco"
9 }
10 }
11 };
12};
13

Values do not need to be URL encoded. For example, "San Francisco" does not require the space to be encoded. A space suffices.

This example sends the following data to the mbox edge:

  • a=1
  • b=2
  • profile.memberStatus=Gold
  • profile.country.city=San Francisco
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.