Skip to content

Instantly share code, notes, and snippets.

<script async="async" src=//consent.trustarc.com/notice?domain=tibco.com&c=teconsent&js=nj&noticeType=bb&gtm=1 crossorigin=""></script>
<script>
window.trustArcCookieCounter = 0;
window.firedTrustArcConsent = false;
//look for the existence of the trust arc cookie that indicates if it's implied or expressed consent
function checkForTrustArcCookie() {
@peter-mcrae
peter-mcrae / Global mbox
Last active August 29, 2015 14:26
Pseudo code for global mbox deployment
<head>
<!-- All the normal stuff that goes in the head tag (ideally jQuery is here so it can be used by T&T offers easily) -->
<script type="text/javascript" src="pathtothemboxjsfile.js"></script>
<script type="text/javascript">
//object that contains any data you have about the customer on the server and want to pass to T&T
var customerInfo = {
};
</script>
<script type="text/javascript">
mboxFactoryDefault.addOnLoad(function () {
var _appendSession = function (_tag) {
var _tags = document.getElementsByTagName(_tag);
for (var i = 0; i < _tags.length; i++) {
var _t = (_tag == 'form') ? _tags[i].action || '' : _tags[i].href || '';
if (_t != '') {
if (_t.indexOf('avascript') == -1 && _t.indexOf('mboxSession=') == -1) {
var _glue = (_t.indexOf('?') > -1) ? '&' : '?';
var _append = _glue + "mboxSession=" + mboxFactoryDefault.getSessionId().getId();
(_tag == 'form') ? _tags[i].action += _append : _tags[i].href += _append
@peter-mcrae
peter-mcrae / T&T - User.ActiveCampaigns
Created July 8, 2013 17:58
It's barely documented, but I think I found a way to create an expression target in T&T to exclude customers that are in a certain campaign. The only thing I don't know is if there is an enforced maximum number of iterations in the for loop. If a customer were in a lot of campaigns (e.g 20), I don't know if it would still work.
//replace 1234 with your campaign
var u = user.activeCampaigns;
for(var i=0,l=u.length;i<l;i++){
if(u[i] == 1234){
return false
}
}
return true;
@peter-mcrae
peter-mcrae / mboxTrackScroll
Last active December 15, 2015 05:39
This snippet will fire a Test & Target AJAX mbox when the user scrolls on the page. It requires jQuery 1.7+. If you are using an older version of jQuery, instead of $(window).on() use $(window).bind()
//accepts an mbox and array of params (name -> value pairs)
var mboxTrackScroll = function (mboxName, params) {
//bind to the scroll event on the window
//namespace the event so we avoid unbinding other handlers
$(window).on('scroll.mboxScroll', function () {
//unbind the handler so we don't fire a gazillion mbox calls
$(this).unbind('scroll.mboxScroll');