Tracking Conversions on Blackbaud ONLINE Express With Google Tag Manager

How Can We Help?

Categories
Table of Contents

Tracking Conversions on Blackbaud ONLINE Express With Google Tag Manager

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("$", ""));

}
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest
Share on email
Email
Share on print
Print