Tracking Conversions on Blackbaud ONLINE Express With Google Tag Manager

Table of Contents

Facebook
Twitter
LinkedIn
Pinterest
Email
Print

Place Code on All pages OLX form lives

<script>
    jQuery(document).ready(function () {

        setTimeout(function () {
            var classSelectors = "#bbox-root";
            var contentDiv = document.querySelector(classSelectors);
            if (contentDiv) {
                var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
                var observer = new MutationObserver(function (mutations) {
                    mutations.forEach(function (mutation) {
                        console.log(mutation);
                        if (mutation.addedNodes.length != 0) {
                            if (mutation.type === "childList" && mutation.addedNodes[0]
                                .className === "BBFormContainer") {
                                console.log(mutation.addedNodes[0].className);
                                if (mutation.addedNodes[0].children[0].className ===
                                    "BBFormConfirmation") {
                                    dataLayer.push({
                                        'event': 'purchase'
                                    });
                                }
                                console.log(mutation.addedNodes[0].children);
                                observer.disconnect();
                            }
                        }
                    });
                });
                var config = {
                    attributes: false,
                    childList: true,
                    characterData: true,
                    subtree: true
                }
                console.log(config);
                observer.observe(contentDiv, config);
                console.log('listening');
            }
        }, 10000);
    });
</script>

Location of Amount

When the trigger event purchase from above code is pushed to dataLayer pull Javascript Variable from GTM

function(){

var start =jQuery('.BBFormConfirmationTransactionDetails span').html().indexOf('$');
var str = jQuery('.BBFormConfirmationTransactionDetails span').html().substring(start);
var end = str.indexOf('<br>');
var price = str.substring(0,end);
  console.log(price);
  return parseFloat(price.replace("$", ""));

}
More to explorer
Wishing You the Joys of the Season!

Once upon a time, in a bustling world filled with shared dreams and aspirations, there existed a group of remarkable individuals who