'GTM Custom HTML Tag and Javascript Variables
I have 2 custom javascript variables (fx_geoLatitude, fx_geoLongitude) that capture latitude and longitude of the user when the page loads on their first session. Firing these variables within a custom HTML tag to populate the console.log is easy enough. I want to populate 2 variables in the data layer with these values, but those variables (latitude, longitude) don't currently exist in our data layer. Is it possible to do this, or do I need to have our dev team update our data layer with these new variables? Also, what would the dataLayer.push in the custom HTML tag look like to do this? Would it be as simple as
(function() {
var latitude={{fx_geoLatitude}};
var longitude={{fx_geoLongitude}};
dataLayer.push({
'latitude' : latitude,
'longitude' : longitude
});
})();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
