javascript - Script to pulled element class inner html for Google Tag Manager -
I am working on a script which means only to pull the paragraph's internal HTML, which is only shown on Blott has gone. I have spent hours on this and have not been able to successfully touch these internal HTML in our data layer.
First of all, the data layer is custom (not the default data layer for GTM) - not sure if it makes a difference.
Secondly, I'm using Javascript to try to get it. The onbroken listener shows a parahaffe (no element id, only with element class) when a user moves through the form (which is the first basic element with an ID, it has many parental elements from the class). Article passes a verification message (for example, enter a valid email) I am trying to pass the error message at the data level:
& lt; Script & gt; Object.onblur = function () {var myForm = document.getElementById ('instantSearchForm'); If (myForm) {var myPara = myForm.getElementsByTagName ('error message'); If (myPara.length) {var para value = mip [0]. WinnerHTML; DataLayer.push ({Input Inner: Para Value}); }} & Lt; / Script & gt; According to your comment, I see that the class to choose your elements is
myForm.getElementsByClassName ('error message'); Instead of
myForm.getElementsByTagName ('error message');
Comments
Post a Comment