Push custom state of an element to GTM

I use Google Tag Manager to implement an analytics tool (posthog). I want to be able to send some custom states of an element as a property of an event. Do I have a way to push a state of the page/specific element as a data layer some how?

Also, do I have a way to push data layer var from a bubble workflow?

If you use javascript with a plugin pushing to the datalayer is as simple as

  dataLayer.push({'color': 'red'});

A common way to do this in bubble would be a clinet-side action in a plugin.

1 Like

Thanks! I’m not sure what plugin, and how to push dynamically all custom states from your answer… Currently I some custom states into the id name of elements and on GTM I created a tag to send analytics if ID of an element is not null.

If you need to push more than one variable just add it to the object that you are pushing. You may want to check gtm documentation to see the right structure for common events.

I prefer to execute the code with a custom plugin that I made, but you can probably use the toolbox plugin.


This topic was automatically closed after 70 days. New replies are no longer allowed.