Menu

Saturday, April 9, 2022

Target Snippets

 1. Check if cookie is present, append query parameter as source code .

if(document.cookie.includes('at_check')) {

  var separator = (window.location.href.indexOf("?")===-1)?"?":"&";

 window.location.href = window.location.href + separator + "SourceCode=INT999T"

}

 

 2. Fire mbox call and update mbox or profie parameters for the mbox which contains offer(i.e Page load with response call) use getOffer or applyOffer

adobe.target.getOffer({

  "mbox": "target-global-mbox",

  "params": {

     "a": 1,

     "b": 2,

     "profile.age": 27,

     "profile.gender": "male"

  },

  "success": function(offer) {

        adobe.target.applyOffer( {

           "mbox": "target-global-mbox",

           "offer": offer

        } );

  },

  "error": function(status, error) {

      console.log('Error', status, error);

  }

});

3. User clicks on any link . Pass the parameter to mbox notification call to track the clicktrack


$('a').click(function(event){

  adobe.target.trackEvent({ "mbox": "clicked-link",

    "params": {

        "param1": "value1"}})

});

4. Pass parameters to global mbox

targetPageParams = function() {
  return {
    "a": 1,
    "b": 2,
    "profile": {
                  "memberStatus": Gold,
                  "country": {
                                "city": "San Francisco"
                            }
              }
  };
};
5. object and method can be used for creating profile script.

Object/Method                      Details
page.url                            The current URL.
page.protocol                        The protocol used for the page (http or https).
page.domain                            The current URL domain (everything before the first                                             slash). For example, www.acme.com in                                                         http://www.acme.com/categories/men_jeans?color=blu                                             e&size=small.
page.query                              The query string for the current page. Everything                                             after the ‘?’. For example, blue&size=small in                                             http://www.acme.com/categories/mens_jeans?                                                    color=blue&size=small.
page.param(‘<par_name>’)                The value of the parameter indicated by <par_name>.                                         If your current URL is Google’s search page and you                                         had inputted page.param('hl'), you would get “en” for                                         the URL http://www.google.com/search?hl=en&                                                 q=what+is+asdf&btnG=Google+Search.
page.referrer              The same set of operations as above apply for referrer and landing                             (i.e. referrer.url is the url address of the referrer).
landing.url,                 Similar to that of page, but for the landing page.
landing.protocol, 
landing.query, and 
landing.param
mbox.name               The active mbox’s name.
mbox.param(‘<par_name>’)                 An mbox parameter by the given name in the active                                             mbox.
profile.get(‘<par_name>’)                 The client-created user profile parameter by the                                     name <par_name>. For example, if the user sets a profile                                     parameter named “gender”, the value can be extracted using                                 “profile.gender”. Returns the value of the “profile.                                        <par_name>” set for the current visitor; returns null if no                                     value has been set. Note that profile.get(<par_name>) is                                     qualified as a function call.
user.get(‘<par_name>’)            Returns the value of the “user.<par_name>” set for the                                         current visitor; returns null if no value has been set.
user.categoryAffinity                Returns the name of the best category.
user.categoryAffinities            Returns an array with the best categories.
user.isFirstSession                Returns true if it’s the visitor’s first session.
user.browser                    Returns the user-agent in the HTTP header. As an example, you                                 can create an expression target to target Safari users only:                             if (user.browser != null && user.browser.indexOf('Safari') != -1)                             { return true; }




6. Flickerlessly to update the image in offer code

(function() {
    Flickerlessly=window.Flickerlessly||{},function(t){"use strict";var e=function(t,e,a,i){var n="atNodeInserted"+t,o="@keyframes "+n+" {from {opacity:0.99} to {opacity:1} }\n";o+=e+"{animation-duration:0.001s;animation-name:"+n+";visibility:hidden}";var s=document.getElementsByTagName("head")[0];if(s){var r=document.createElement("style");r.setAttribute("type","text/css"),r.styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),s.insertBefore(r,s.firstChild)}var c=function(t){if(t.animationName===n&&"object"==typeof t.target){var o=!0===i||!1===i&&null===t.target.getAttribute("data-flk-success");console&&console.info&&console.info("Node "+e+" ready! Execute: "+o,t.target),"function"==typeof a&&o&&(a(t.target),t.target.setAttribute("data-flk-success",n)),t.target.style.visibility="visible"}};["animationstart","MSAnimationStart","webkitAnimationStart"].forEach(function(t,e){document.addEventListener(t,c,!1)})};t.onReady=function(){for(var t=0;t<arguments.length;t++){var a=arguments[t],i=a.selector,n=a.success||null,o=a.persist||!1,s=Math.floor(100*Math.random()+1);e(s,i,n,o)}}}(Flickerlessly);

    Flickerlessly.onReady({
        selector: "#sc-lb-module-sc-inline-banner > div.sc-bnr__bg-wrapper > img",
        persist: true,
        success: function(el) {
            injMbox.domManipulation();
        }
    });

    var injMbox = injMbox || {
        domManipulation: function() {
            document.querySelectorAll("#sc-lb-module-sc-inline-banner > div.sc-bnr__bg-wrapper > img")[0].src = "https://www.jio.com/jio.comm.jpg"
        }
    };
})();









No comments:

Post a Comment

Target Server Side implementation using .net SDK

 Target Server Side implementation using .net SDK  This reference guide shows how Adobe Target customers can install, initialize, and use th...