Highlighted

Is it possible to grab a page element and store it as a data source? I have a product page which displays the sku on it and I'd like to grab this and field and make it a data source for my analytics tags.

Rookie Contributor
I'm also hoping to grab a hidden field and make it a data source. Is this also possible?
1 REPLY 1
Highlighted

Is it possible to grab a page element and store it as a data source? I have a product page which displays the sku on it and I'd like to grab this and field and make it a data source for my analytics tags.

Employee Emeritus
Hi Jeremy, What you're referring to is what's called scraping. While it is possible, it's not something we recommend. Data scraping relies on the structure of the webpage remaining static since it's looking for these elements in the same place. If the site were to undergo a redesign, even a minor one, it's likely these elements will shift around and thus your 'scraped' data layer will break. There is also another issue in that some JavaScript libraries will populate this kind of data after DOM ready, which can cause problems in the timing/order of operations of how your tags fire. Short answer: yes, but it's not recommended or best practice. Realistically, sometimes you have to do this if your development team can't populate the UDO as we recommend, but it should always be considered a short-term fix. If you need assistance with this please contact your account manager. Hope this helps!