Created
February 11, 2020 09:33
-
-
Save postman31/d29ff54f0d0d48630175c86ecc1f0cd5 to your computer and use it in GitHub Desktop.
sample parsing:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cunstom function | |
function () { | |
var divList = document.querySelectorAll('.bx-soa-section-content div') | |
var content = Array.prototype.reduce.call(divList, function(res, el, ind) {if (el.innerText != '') { var s = el.innerText.split(/\:\s*/); res['field_'+ind] = s[1];} ; return res }, {} ) | |
return content['field_1'] // chose other index for the necessary field | |
} | |
// dataLayer | |
var divList = document.querySelectorAll('.bx-soa-section-content div') | |
var content = Array.prototype.reduce.call(divList, function(res, el, ind) {if (el.innerText != '') { var s = el.innerText.split(/\:\s*/); res[s[0]] = s[1];} ; return res }, {} ) | |
dataLayer.push(content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment