Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 795 Bytes

File metadata and controls

36 lines (25 loc) · 795 Bytes

Pushing Data

Pushing to the data layer

To push a key value pair to the dataLayer you can simply call the data method within your controller files. You can call the method as many times as you want to push values to the data layer. The key value pairs will generate the necessary data layer JavaScript code.

GTM::data('key','value')

outputs:

window.dataLayer = window.dataLayer || [];
dataLayer = [{
    'key' : 'value'
}];

Pushing an event to the data layer

Events play a very important part in a lot of custom Google Tag manager tracking. You can push an event easily with the event method.

GTM::event('MyEvent')

outputs:

dataLayer = [{
    'event' : 'MyEvent'
}];

Next: Pushing Ecommerce data