Expand my Community achievements bar.

SOLVED

Success Metric if Cookie Value Changed

Avatar

Level 1

I cannot place an MBOX on my success confirmation page, so instead I would like to check the value of a cookie to determine if there was a success. When the user returns to my homepage, i would like to check the value of that cookie and remove them from the test and trigger a success.

Possible?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

If the confirmation page uses the same domain as your test entry the mbox cookie is available on the confirmation page. If you can add a script to the page that pulls the session ID and PC ID out of the mbox cookie you can manually fire a confirmation mbox request from the page without the library file. Here is a sample JS tag that will do this:

if (document.cookie.indexOf('mbox=') != -1) { var mbxSes = document.cookie.match(/session#[0-9]+?-[0-9]+?#/).toString().split('#');     var mbxPC = document.cookie.match(/PC#[0-9]+?-[0-9]+?\.[0-9][0-9]_[0-9][0-9]#/).toString().split('#');     var img = new Image();     img.src = "//CLIENTCODE.tt.omtrdc.net/m2/CLIENTCODE/ubox/image?mboxSession="+mbxSes[1]+"&mboxPC="+mbxPC[1]+"&mbox=orderConfirmation&mboxURL="+encodeURI(document.location.href)+"&mboxReferrer="+encodeURI(document.referrer)+"&mboxDefault=ENCODEDGIFURL&mboxXDomain=disabled"; }

You'll have to update your CLIENTCODE value and add an encode gif url (ideally a 1x1 gif on your site) for the value of mboxDefault. This will fire an mbox called: orderConfirmation. You can then configure your success metric in your test to look for this mbox.

NOTE: if you are using at.js the match regex for the session and PC variables will need to be different as at.js stores those sessions with alphanumberic values not just numeric values. These should work:

    var mbxSes = document.cookie.match(/session#[a-z0-9]+?#/).toString().split('#'); var mbxPC = document.cookie.match(/PC#[a-z0-9]+?\.[0-9][0-9]_[0-9][0-9]#/).toString().split('#');

View solution in original post

5 Replies

Avatar

Level 10

Hi Sam,

It is possible by reading the browser cookies on the confirmation page by using profile scripts and then Set a profile script to true, once a user visits confirmation and then use it to disqualify the audience from a campaign.

Thanks & Regards

Parit Mittal

Avatar

Employee Advisor

Hi Sam,

Short answer: You can do what you are suggesting. It requires custom JS on the confirmation page to set the cookie, and then separate JS on the home page to evaulate it and send a custom mbox parameter to Target on that page. However, it has some issues and gaps (namely only people returning to the home page after confirmation will actually get tracked as a confirmation), but maybe it is the best you can get without an mbox request firing on the confirmation page.

Follow up question: What do you mean you cannot place an MBOX on your success confirmation page? Do you mean you can NOT add the Target library (mbox.js/at.js) to that page to fire an mbox request? Or is it something separate? There are alternative ways to fire a confirmation type mbox request so you might be better off evaluating these options first.

Avatar

Level 1

Thanks for your response Ryan, you are correct, i cannot add the Target Library to my confirmation page, i would like to find out more about the alternative ways to fire a confirmation type mbox request, can you provide me any info about that please?

Thanks

Sam

Avatar

Correct answer by
Employee Advisor

If the confirmation page uses the same domain as your test entry the mbox cookie is available on the confirmation page. If you can add a script to the page that pulls the session ID and PC ID out of the mbox cookie you can manually fire a confirmation mbox request from the page without the library file. Here is a sample JS tag that will do this:

if (document.cookie.indexOf('mbox=') != -1) { var mbxSes = document.cookie.match(/session#[0-9]+?-[0-9]+?#/).toString().split('#');     var mbxPC = document.cookie.match(/PC#[0-9]+?-[0-9]+?\.[0-9][0-9]_[0-9][0-9]#/).toString().split('#');     var img = new Image();     img.src = "//CLIENTCODE.tt.omtrdc.net/m2/CLIENTCODE/ubox/image?mboxSession="+mbxSes[1]+"&mboxPC="+mbxPC[1]+"&mbox=orderConfirmation&mboxURL="+encodeURI(document.location.href)+"&mboxReferrer="+encodeURI(document.referrer)+"&mboxDefault=ENCODEDGIFURL&mboxXDomain=disabled"; }

You'll have to update your CLIENTCODE value and add an encode gif url (ideally a 1x1 gif on your site) for the value of mboxDefault. This will fire an mbox called: orderConfirmation. You can then configure your success metric in your test to look for this mbox.

NOTE: if you are using at.js the match regex for the session and PC variables will need to be different as at.js stores those sessions with alphanumberic values not just numeric values. These should work:

    var mbxSes = document.cookie.match(/session#[a-z0-9]+?#/).toString().split('#'); var mbxPC = document.cookie.match(/PC#[a-z0-9]+?\.[0-9][0-9]_[0-9][0-9]#/).toString().split('#');