• Internet Marketing
    • Google Analytics
    • Google Tag Manager
    • SEO
    • Content
    • Marketing Automation
    • Social Media
    • PPC
  • Technology
    • Mobile
    • ISP
    • Hosting
    • Tools & Services
  • Resources
    • Useful And Unique Sites
    • Google Analytics Referral Spam Filters
    • Google Analytics URL Builder for Custom UTM Codes
  • Contact
www.gregcruce.com
  • Internet Marketing
    • Google Analytics
    • Google Tag Manager
    • SEO
    • Content
    • Marketing Automation
    • Social Media
    • PPC
  • Technology
    • Mobile
    • ISP
    • Hosting
    • Tools & Services
  • Resources
    • Useful And Unique Sites
    • Google Analytics Referral Spam Filters
    • Google Analytics URL Builder for Custom UTM Codes
  • Contact
Data Layer Push for Google Tag Manager
12 July 2015

Using dataLayer.push? Include An Event To Fire Tags in Google Tag Manager

Written by Greg Cruce
Google Tag Manager 4 Comments
Share

If you use the dataLayer.push method in Google Tag Manager to add data to your datalayer, you’ll want to include a Google Tag Manager Data Layer Event as well. Using a datalayer event, you can then fire a Custom Event Trigger. Using this setup will allow you fire any necessary tags to read any newly pushed data. Here’s how you set it up.

Add An Event To dataLayer.push

Once your code has completed, you’ll want to fire the final datalayer event, so that Tag Manager can intercept the event in the next step. It’s important to fire any events that need the data as quickly as possible, rather than stacking them. Here’s what we will change:

dataLayer.push({
'var1':'value'
});

To become this. Notice the addition of the comma on the previous line!

dataLayer.push({
'var1':'value',
'event':'sendUpdate'
});

Set Up A Trigger To Fire

Now that we have our event taken care of in the code, we’ll want to create a new Trigger to listen for this event to fire. To create this trigger, select “Custom Event” as the type, and give the Event Name the same value and case as we programmed above.

custom-event-trigger

Update Tag To Use The New Trigger

Now we can update our tag to use the newly created trigger to fire.  Select “More” from the “Fire On” step, and select our trigger

trigger-to-fire-tag

In this way, we can ensure that our Data Layer handles the data, and any tags that are needed can be fired as quickly as possible.

 

Join other digital marketers who have a head start

Free online marketing tips and resources delivered to your inbox

No charge. Unsubscribe anytime

dataLayer, dataLayer.push, Trigger
Greg Cruce

Greg has over 20 years of combined experience in the disciplines of web development, computer programming, IT, and Internet marketing and strategy. This unique skillset allows for powerful insights from consulting, strategy, execution and analysis.

4 Comments

  1. Martin Reply to Martin to Martin" aria-label=' Reply to Martin to Martin'> Reply to Martin
    February 19, 2016 at 11:18 am

    Hi, great post!

    Once I’ve set up the trigger like you’ve done, what should I do in the Tag configuration?

    I understand that I need to pick my trigger in the “Fire on” section, but what should I pick in the Configure Tag section? Is it pageview or event or transaction or what?

    Confused here :-)

    • Greg Cruce Reply to Greg to Greg Cruce" aria-label=' Reply to Greg to Greg Cruce'> Reply to Greg
      February 19, 2016 at 3:35 pm

      Hi Martin!

      Well, that entirely depends on what you are firing the event for! Most of the time I use data layer push to fire Events into Google Analytics. You may have a different setup or need – what is it you’re trying to do?

  2. Nik Reply to Nik to Nik" aria-label=' Reply to Nik to Nik'> Reply to Nik
    December 14, 2015 at 1:28 am

    Hello Greg, Thank you for the wonderful post. I was looking for this only. I have a query – once this is done, how can we pass this custom event in GA so that I can check data in Top Events report?

    • Greg Cruce Reply to Greg to Greg Cruce" aria-label=' Reply to Greg to Greg Cruce'> Reply to Greg
      December 18, 2015 at 9:43 am

      Hello Nik,

      Great question! Once you’ve gotten your event to fire, you’ll then want to add a Trigger to Google Tag Manager to listen for that custom event. Once your Trigger is set, then create a Google Analytics Event, and have it fire from the Trigger. So, the order of operations are: custom event fires the trigger, and the trigger fires the tag. Thanks!

Leave a Reply

Cancel reply

www.gregcruce.com

The professional blog by Greg Cruce, an Internet and Digital Marketing professional.

  • About Me
  • Subscribe to RSS
  • Connect via LinkedIn
  • Connect via Twitter

Posts

  • Google Analytics Custom Metrics
    Google Analytics Calculated Metrics (with examples)
  • #MyComcastSpeed – My 96% reduction in peak to non-peak
  • iOS8 Drops Camera Roll (Update: It’s back with 8.1)

Services

  • Google Analytics Consulting
copyright www.gregcruce.com