Help adding tag with Custom Container

mark_jaggers
Visitor
mark_jaggers

I do not utilize the custom container enough and I have been struggling with a tag that I am sure is easy to implement but not working for me.  Here is the tag I have been trying to configure using a custom container.  I have read some of the tutorials and even my old notes but I still cant seem to get it to work.  I was hoping someone could point me in the right direction.

 

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
  "palette": {
    "popup": {
      "background": "#efefef",
      "text": "#404040"
    },
    "button": {
      "background": "#8ec760",
      "text": "#ffffff"
    }
  },
  "theme": "classic",
  "content": {
    "message": "Test content",
    "dismiss": "OK",
    "link": "Readthis",
    "href": "www.test.com/cookie"
  }
})});
</script>

 

thanks

3 REPLIES 3

Help adding tag with Custom Container

Tealium Employee
 
//~~tv:20010.20140827
//~~tc: Tealium Custom Container

/* Start Tag Library Code */
(function() {
  if (!document.querySelector('#cookie_consent_css')) {
    var link = document.createElement('link');
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = "//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css";
    link.id = 'cookie_consent_css';
    document.head.appendChild(link);
  }
})();
/* End Tag Library Code */
//tealium universal tag - utag.sender.custom_container ut4.0.##UTVERSION##, Copyright ##UTYEAR## Tealium.com Inc. All Rights Reserved.
try {
    (function (id, loader) {
        var u = {};
        utag.o[loader].sender[id] = u;
        // Start Tealium loader 4.32
        // Please do not modify
        if (utag === undefined) { utag = {}; } if (utag.ut === undefined) { utag.ut = {}; } if (utag.ut.loader === undefined) { u.loader = function (o) { var a, b, c, l; a = document; if (o.type === "iframe") { b = a.createElement("iframe"); b.setAttribute("height", "1"); b.setAttribute("width", "1"); b.setAttribute("style", "display:none"); b.setAttribute("src", o.src); } else if (o.type === "img") { utag.DB("Attach img: " + o.src); b = new Image(); b.src=o.src; return; } else { b = a.createElement("script"); b.language = "javascript"; b.type = "text/javascript"; b.async = 1; b.charset = "utf-8"; b.src=o.src; } if (o.id) { b.id = o.id; } if (typeof o.cb === "function") { if (b.addEventListener) { b.addEventListener("load", function () { o.cb(); }, false); } else { b.onreadystatechange = function () { if (this.readyState === "complete" || this.readyState === "loaded") { this.onreadystatechange = null; o.cb(); } }; } } l = o.loc || "head"; c = a.getElementsByTagName(l)[0]; if (c) { utag.DB("Attach to " + l + ": " + o.src); if (l === "script") { c.parentNode.insertBefore(b, c); } else { c.appendChild(b); } } }; } else { u.loader = utag.ut.loader; }
        // End Tealium loader
        u.ev = {'view' : 1};
        u.initialized = false;
        ##UTGEN##
        u.send = function(a, b) {
            if (u.ev[a] || u.ev.all !== undefined) {
                //##UTENABLEDEBUG##utag.DB("send:##UTID##");
                var c, d, e, f, i;
                u.data = {
                    base_url: '//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js',
                    config: {
                        "palette": {
                            "popup": {
                                "background": "#efefef",
                                "text": "#404040"
                            },
                            "button": {
                                "background": "#8ec760",
                                "text": "#ffffff"
                            }
                        },
                        "theme": "classic",
                        "content": {
                            "message": "Test content",
                            "dismiss": "OK",
                            "link": "Readthis",
                            "href": "www.test.com/cookie"
                        }
                    }
                };
                /* Start Tag-Scoped Extensions Code */
                /* Please Do Not Edit This Section */
                ##UTEXTEND##
                /* End Tag-Scoped Extensions Code */
                /* Start Mapping Code */
                for (d in utag.loader.GV(u.map)) {
                    if (b[d] !== undefined && b[d] !== "") {
                        e = u.map[d].split(",");
                        for (f = 0; f < e.length; f++) {
                            u.data[e[f]] = b[d];
                        }
                    }
                }
                /* End Mapping Code */
                /* Start Tag Sending Code */
                // Insert your tag sending code here.
                /* End Tag Sending Code */
                /* Start Loader Callback Function */
                u.loader_cb = function() {
                    u.initialized = true;
                    window.addEventListener('load', function(event) {
                        if (window.cookieconsent && window.cookieconsent.initialise) {
                            window.cookieconsent.initialise(u.data.config);
                        };
                    })
                };
                /* End Loader Callback Function */
                /* Start Loader Function Call */
                /* Un-comment the single-line JavaScript comments ("//") to use Loader. */
                if (!u.initialized) {
                    u.loader({
                        "type": "script",
                        "src": u.data.base_url,
                        "cb": u.loader_cb,
                        "loc": "script",
                        "id": 'utag_##UTID##'
                    });
                } else {
                    u.loader_cb();
                }
                /* End Loader Function Call */
                //##UTENABLEDEBUG##utag.DB("send:##UTID##:COMPLETE");
            }
        };
        utag.o[loader].loader.LOAD(id);
    })("##UTID##", "##UTLOADERID##");
} catch (error) {
    utag.DB(error);
}
//end tealium universal tag

Help adding tag with Custom Container

kathleen_jo
Employee Emeritus
kathleen_jo

Wow! Just WOW @Mauricio!! @mark_jaggers better accept that as a solution!!!  #HintHintWinkWink

Remember to give me a kudo if you like my post! Accepting my post as a solution is even better! Also remember that search is your friend.

Help adding tag with Custom Container

mark_jaggers
Visitor
mark_jaggers

Thank you for your help @Mauricio. This is great and now it gives me something to reference for other similar tags.