I found this great script that does the job of collecting JSON to a specific triggered area of my site.
I would like to parse xhr.responseText
to collect only ID_number
.
Here is the script:
<script>
(function() {
var xhrSend = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function() {
var xhr = this;
var intervalId = window.setInterval(function() {
if(xhr.readyState != 4) {
return;
}
dataLayer.push({
'event': 'ajaxSuccess',
'eventCategory': 'AJAX',
'eventAction': xhr.responseURL,
'eventLabel': xhr.responseText
});
clearInterval(intervalId);
}, 1);
return xhrSend.apply(this, [].slice.call(arguments));
};
})();
</script>