Post by account_disabled on Mar 5, 2024 17:29:17 GMT -9
The with JavaScript andor jQuery within the custom HTML tag. In the context of SEO changes the most common place where youll want to extract data from the page would be to construct structured data markup using JSONLD. In order to demonstrate the different methods Ill show a way of constructing product markup by extracting items both in GTM variables and within a custom HTML tag. For this example we can imagine a site with product pages that have data about their products each given unique IDs within the HTML of the page. In reality youll need to find CSS selectors that give you the exact elements youre looking for. A great tool for this is the Selector Gadget Chrome extension that allows you to find a unique CSS selector for any element on a page.
For our example lets imagine the following IDs Element t_ID Associated Greece Mobile Number List Schema Item producname name product_img image price_value price price_currency priceCurrency ratings_count reviewCount avg_rating ratingValue Using GTM variables If youre using GTM variables to pull the data out of the page youll need to set up a variable for each of the above elements. menu and clicking NEW under UserDefined Variables. For each of the above elements define a new DOM Elementtype variable using an ID or CSS selector appropriate to each item.
For all of the above youll want to leave the Attribute Name field blank except for the image where youll want to extract the src attribute. Screen Shot at ...png In order to pull these variables into some JSONLD markup well need to set up a custom HTML tag that references them. Screen Shot at ...png Note that in order to reference a GTM variable you need to wrap them in double curly brackets. Also note that weve referenced Page URL which is a default builtin variable in GTM. The last four lines of this script are turning the jsonData element into part of a script element with type applicationldjson to be injected into the.
For our example lets imagine the following IDs Element t_ID Associated Greece Mobile Number List Schema Item producname name product_img image price_value price price_currency priceCurrency ratings_count reviewCount avg_rating ratingValue Using GTM variables If youre using GTM variables to pull the data out of the page youll need to set up a variable for each of the above elements. menu and clicking NEW under UserDefined Variables. For each of the above elements define a new DOM Elementtype variable using an ID or CSS selector appropriate to each item.
For all of the above youll want to leave the Attribute Name field blank except for the image where youll want to extract the src attribute. Screen Shot at ...png In order to pull these variables into some JSONLD markup well need to set up a custom HTML tag that references them. Screen Shot at ...png Note that in order to reference a GTM variable you need to wrap them in double curly brackets. Also note that weve referenced Page URL which is a default builtin variable in GTM. The last four lines of this script are turning the jsonData element into part of a script element with type applicationldjson to be injected into the.