Using custom mbox parameter variables in experience events | Community
Skip to main content
New Participant
February 23, 2021
Solved

Using custom mbox parameter variables in experience events

  • February 23, 2021
  • 1 reply
  • 2165 views


I'm using targetPageParams to add a parameter into the mbox (default mbox), lets call it "MyParam". 

In my script its pulling in a querystring parameter and setting a custom mbox parameter to the value found there.

Example URL: [my URL]?TESTParam=xyz123

I know Target has seen  "MyParam" in the mbox because it offers that parameter ("MyParam") as way to build audiences off of, in "Custom" rules. 


That being said..if I wanted to create an experience that now uses the value found in MyParam on the page, let's say appending it to a text field. How can I do that? I tried using ${mbox.MyParam} in a SetHTML modification for a text area in the content section. This did not appear to render anything. 

What am I missing? Is the syntax ${mbox.MyParam} for adding that mbox variable to the page correct? Is there another way to do it? 

 

 

Here is the script...I'm injecting it via a tag management application and pushing it out before all other load rules:
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var MyParam = "";
if (urlParams.has('TESTParam')) {

MyParam= urlParams.get('TESTParam');

targetPageParams = function(){ return ["MyParam=" + MyParam]; }

; }

console.log('MyParam: ' + MyParam);

Additionally...if the syntax is correct, could it be that you can't insert an mbox parameter and pull it back out in the same page? I figured I might be able to depending on the order of the calls (insert first, mbox fill, target audience check, target experience delivered - with custom mbox param item, page render)..but I'm not sure if that is the load sequence.

 

Thanks for any help. 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jchristman
Additionally...if the syntax is correct, could it be that you can't insert an mbox parameter and pull it back out in the same page? I figured I might be able to depending on the order of the calls (insert first, mbox fill, target audience check, target experience delivered - with custom mbox param item, page render)..but I'm not sure if that is the load sequence.

1 reply

New Participant
February 24, 2021

@jchristman Can you share the mark up and the screenshot of the call to Target with the parameter being passed in?

 

Thanks!

New Participant
February 24, 2021

Here is the script...I'm injecting it via a tag management application and pushing it out before all other load rules:
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var MyParam = "";
if (urlParams.has('TESTParam')) {

MyParam= urlParams.get('TESTParam');

targetPageParams = function(){ return ["MyParam=" + MyParam]; }

; }

console.log('MyParam: ' + MyParam);