Capture the value of an HTML variable
I want to read the value of a variable in an HTML page, and report it to Google Analytics.
The line in question is this:
<h1 id="results-heading">Your search for <span class="query"></span> returned <span class="total-results"></span> result(s).</h1>
I want to capture the value of the "query" variable.
Re: Capture the value of an HTML variable
If you are not using GTM, then your dev team could create code that would get the value and set it for your. How you set it is really a function of how you would use the data. That is it could be passed into the GATC as a virtual pageview or set as a custom dimension.
Links for your reference:
Modifying Pageviews (virtual)
CJS - GTM via Simo Ahave.. king of GTM dev.
That said, this looks like a search result, is it? If so is the query also exposed in the address bar? If so, that could be captured in site search settings.
Hope that helps!