![]() Get CSS selectorAfter you know where you can get the necessary data in DOM, it is time to translate that information into machine language □ so that GTM knows where to search this data as well.If you don't know what is a CSS selector, please check this lovely article from MDNĢ. Identify where your data is locatedThere might be multiple places where you can get required data (or none), so before any tags are created, inspect your page code and select the most reliable source. If you just use the value from the website straight away, that probably wouldn't work, so you need to additionally plan to re-format your price in the required format. But your tag requires a number of 1000.99. It is a good idea to check if the value you have on the website will need additional “cleaning up” before it is sent to your analytics tool.įor example: On your website, you have a dynamic product price that is formatted like so 1,000.99$. ![]() ![]() Define what tag needs the data and what is a formatting requirementĭepending on the tracking code, the formatting of the same value (e.g.Start with a short planīefore you create a variable in GTM to extract data from the website it is a good idea to start with a plan so that it’s more clear what will be necessary for the setup. If you haven’t done so already, you can check Wikipedia for a more detailed explanation as well, we will not dive deep into that topic in this article 1. So that’s basically is the DOM, if we keed it simple □ You have probably seen similar HTML structure in your browser console: Document in the case of the webpage is HTML code, where each element or “node” represents part of the page and has it’s own place or “address” in the structure. Or if the first option would take too much effort – you could try to extract it using Google Tag Manager from your HTML.ĭOM stands for Document Object Model that represents a document with a logical tree.Ask a developer to make this information available (JavaScript variable, local storage, cookie, etc.).If you have this information in your data layer – that’s perfect, you can use dataLayer variable!īut very often I find myself in a situation when I don’t have enough data available in a structured form that is ready to be consumed by marketing and analytics tags, and in such cases, you would normally have 2 options: Let’s imagine that you want to send your product name or product price information alongside with Google Analytics or Facebook event as soon as any of your products are viewed. In this article, we will take a look at how to use Google tag manager DOM element variable to extract pieces of data directly from your website HTML code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |