Expand my Community achievements bar.

How can I get all the expriences info on my pape with javascript?

Avatar

Former Community Member

I have made Exprience A and Exprience B, now  I want to get all the expriences on my test page with javascript,

how should I do ?

thanks a lot !

6 Replies

Avatar

Employee Advisor

Hi Tut,

Are you asking how to see your Experience A and/or B on your page? For QA purposes? If so you can use the preview experiences links found on the overview tab of an activity. That will load the page and render the chosen experience. Please add more details if I'm misunderstanding your question.

Avatar

Level 1

I'm not exactly sure what you want, but you could use the ttMETA test plugin, or use some combination of the mboxTrace, mboxDebug and authorization URL parameters to get information in your browser inspector console, or even in the JSON returned from the at.js call to the cloud.

Avatar

Level 1

I also have this as a bookmark in Google Chrome.

atdebug

javascript:void(0);!function(){function e(e,t){function n(){return t.isObject(e.XMLHttpRequest)}function o(){return n()&&"onload"in new e.XMLHttpRequest}function r(){return o()&&"withCredentials"in new e.XMLHttpRequest}function a(){return t.isObject(e.XDomainRequest)}return{isXhrSupported:n,isStandardXhrSupported:o,isStandardCrossDomainXhrSupported:r,isIeCrossDomainXhrSupported:a}}var t={getItem:function(e){return e?decodeURIComponent(document.cookie.replace(RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:null},setItem:function(e,t,n,o,r,a){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var i="";if(n)switch(n.constructor){case Number:i=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:i="; expires="+n;break;case Date:i="; expires="+n.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+i+(r?"; domain="+r:"")+(o?"; path="+o:"")+(a?"; secure":""),!0}},n=function(){for(var e,t=3,n=document.createElement("div");n.innerHTML="<!--[if gt IE "+ ++t+"]><i></i><![endif]-->",n.getElementsByTagName("i")[0];);return t>4?t:e}(),o={isObject:function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)},isString:function(e){var t=typeof e;return!!e&&"string"==t},isFunction:function(e){var t=Object.prototype,n=t.toString,o=o="[object Function]";return this.isObject(e)&&n.call(e)==o},ie:n};!function(e,t,n){function o(e,t){return{name:e,value:t}}function r(e){var t,n=!0;for(t=0;t<e.length;t+=1)if(!e[t].value==!0){n=!1;break}return n}var a,i,s,u,c,l,p,d,b,m,h,f,g,v,S,k,E,y,x,R,w,L=[],C="zCookieName"+(new Date).getTime(),I="zCookieValue"+(new Date).getTime();e.setItem(C,I),a=I===e.getItem(C),L.push(o("browser allows cookies: ",a)),i=t.isStandardXhrSupported(),L.push(o("browser supports XMLHttpRequest",i)),n.ie?L.push(o("browser supports XDomainRequest",t.isIeCrossDomainXhrSupported())):L.push(o("browser supports XMLHttpRequest withCredentials (CORS)",t.isStandardCrossDomainXhrSupported())),s=[];try{s.push(o("mboxUpdate",n.isFunction(mboxUpdate))),s.push(o("mboxCreate",n.isFunction(mboxCreate))),s.push(o("mboxDefine",n.isFunction(mboxDefine)))}catch(j){}u=s.length?r(s):!1,L.push(o("mboxCreate, mboxDefine, mboxUpdate available",u)),c=[{key:"applyOffer",value:"isFunction"},{key:"executeAjax",value:"isFunction"},{key:"getOffer",value:"isFunction"},{key:"getSettings",value:"isFunction"},{key:"getTracking",value:"isFunction"},{key:"trackEvent",value:"isFunction"},{key:"VERSION",value:"isString"}],l=[],p="",d=["support for:"];try{if(n.isObject(adobe)&&n.isObject(adobe.target)){for(b=0;b<c.length;b++)m=c[b],l.push(o("adobe.target."+m.key,n[m.value](adobe.target[m.key])));p=adobe.target.VERSION}}catch(j){}for(b=0;b<c.length;b++)m=c[b],h=m.key,"isFunction"===m.value&&(h+="()"),d.push("adobe.target."+h);if(f=l.length?r(l):!1,L.push(o(d.join("<br/>"),f)),g=window.open("","","width=700,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1")){for(v="<h2>at.js readiness <small>{VERSION}</small></h2>",S=v.replace("{VERSION}",p?"(v."+p+")":""),k=["<html><head>",'<link rel="stylesheet" href="https://forums.adobe.com//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">','</head><body><div class="container">',S,'<table class="table-bordered table">'],E='<tr class="{TYPE}"><td>{LABEL}</td><td>{VALUE}</td></tr>',b=0;b<L.length;b++)y=E.replace("{LABEL}",L[b].name).replace("{VALUE}",L[b].value?"ok":"error"),y=y.replace("{TYPE}",L[b].value?"success":"danger"),k.push(y);return x=["</table>","</div></body>","</html>"],void g.document.write(k.concat(x).join("\n"))}for(R="at.js readiness {VERSION}:".replace("{VERSION}",p?"(v."+p+")":""),w=[R],b=0;b<L.length-1;b++)w.push("\n"+"{LABEL}:  {VALUE}".replace("{LABEL}",L[b].name).replace("{VALUE}",L[b].value));w.push("\nadobe.target.*:  "+L[L.length-1].value),console&&console.log?console.log(w.join("")):alert(w.join(""))}(t,e(window,o),o)}();

Avatar

Level 1

And also this more useful one bookmarked. It's good for checking on Analytics variables too.

AA

javascript:void(window.open("","dp_debugger","width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1").document.write("<script language=\"JavaScript\" id=dbg src=\"https://www.adobetag.com/d1/digitalpulsedebugger/live/DPD.js\"></"+"script>"));

Avatar

Level 2

Hey,

I was having this same problem and posted here about it. I eventually found a hacky way around it. Here is the answer to my own post. Hope this helps:

Is there a way to get test metadata through the browser.

Avatar

Level 3

Hey anthonym75181935​ & netxpressd4442685​ & tut54841492,

Not sure if this was completely resolved. However there are 2 ways to do it from what I can see. I have tried and tested both and they help resolve what I needed. This could definitely work (please modify it according to your needs):

Option 1: ttMETA plugin

ttMETA (a response tokens plugin that needs to be activated for specific data points that needs to be thrown into the window object).

Steps to do this:

  • Activate the specific response token you would require from the Setup (top navigation menu) >> Response Tokens (left navigation menu)

1662424_pastedImage_3.png

  • Then go to Offers (top navigation menu) >> Code offers (left navigation menu) and create an HTML offer (if it doesn't already exist). Name it ttMETA. Add the following code after that.

    1662437_pastedImage_7.png

<script type="text/javascript">

/*T&T Metadata v3 ==>Response Plugin*/

window.ttMETA=(typeof(window.ttMETA)!="undefined")?window.ttMETA:[];window.ttMETA.push({"CampaignName":"${campaign.name encode="escape"}","CampaignId":"${campaign.id encode="escape"}","RecipeName":"${campaign.recipe.name encode="escape"}","RecipeId":"${campaign.recipe.id encode="escape"}","OfferId":"${offer.id encode="escape"}","OfferName":"${offer.name encode="escape"}","MboxName":"${mbox.name encode="escape"}"});

</script>

Here is all the documentation you would actually need for this:

Useful Variables, Profiles, Parameters, and Methods

Target Troubleshooting - YouTube at 12:00 mins

AFAIK, the ttMETA plugin is from the mbox.js days and it has backward compatiblilty with mbox.js. It should definitely work with at.js

Option 2: Add event listener to your test pages

This is the more newer way of doing things. This option has slightly more code than option 1, but nevertheless would still work great.

Target documentation states that you can add an event listener when Target is loaded, Target is executed etc etc.

Documentation present here: Response tokens . On this page look at the code at the very bottom of the page. Run the code that is provided there on document load as an event listener when Target is loaded/ executed/ fails etc. and then push out appropriate messages into console or wherever it is you have to send about the Activity and Experience details.

Steps:

  • Activate the specific response token you would require from the Setup (top navigation menu) >> Response Tokens (left navigation menu) - See first screenshot from my answer.
  • Write the below JS in

<script type="text/javascript">

document.addEventListener(adobe.target.event.LIBRARY_LOADED, function(e) {

          console.log("Adobe Target Library Loaded", e.detail);

});

document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function(e) {

          console.log("Adobe Target Request Succeeded", e.detail);

          // e.details.responseTokens contains the Activity and Experience details that you would need.

          // add required JS snippets additionally here.

});

...

</script>

Add breakpoints in your code to see it work as expected.

1662446_pastedImage_12.png

Hope this helped!