Skip to content

Instantly share code, notes, and snippets.

@postman31
Created February 11, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postman31/d29ff54f0d0d48630175c86ecc1f0cd5 to your computer and use it in GitHub Desktop.
Save postman31/d29ff54f0d0d48630175c86ecc1f0cd5 to your computer and use it in GitHub Desktop.
sample parsing:
// 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