I’m trying to set up GTM and use the dataLayer to pass data from my pages to Analytics & Facebook for tracking purposes. Things like page title, price of the product, etc. To do this, I need to push to the GTM dataLayer.
Docs say to instantiate the dataLayer before the GTM code (which itself goes right after the opening tag.
My issue is how to do this in Jekyll with includes, etc. because, depending on the specific page (landing page asking for an email sign up vs a product purchase page), the dataLayer key/value pairs will be different.
I think an IF this page type (landing page), THEN this dataLayer code, ELSE the other type. But I’m not getting it put together correctly.
Anyone have a working example of how they set this up that they’d be willing to share? Or general ideas on an approach. I’m afraid I’m over thinking it but can’t simplify.
I’ll get in my computer in a bit and work through that more carefully but on reading through it, I think that’ll get me there. Thanks. Just couldn’t get it fixed in my head how to construct it.