Add a custom event that triggers a goal in GA with GTM

1. Make sure that GTM is fully configured and activated on your site
2. Push an event to the dataLayer when you want it to happen… for example inside an eventlistener…
3. We will call this event “myevent” and the variable for the event “myeventResult”. These should be changed to something descriptive depending on what type of event you are capturing…

    dataLayer.push({
	"event" : "myevent",
	"myeventResult" : "success"
    });

 

 

4. Go to GTM and add a variable,
5.name it

GA - myevent Result

6.choose “Data Layer Variable” in the list of variable types
7.write

myeventResult 

in the Data Layer Variable Name, IMPORTANT THAT IT MATCHES THE VARIABLE NAME EARLIER FROM STEP 3.
8.Set Default Value to either

0

or

not set

, depending on what you are doing..
9.Save
10. Go to Triggers, Add new
11. Name it

GA - myevent Conversion

12. Choose Custom Event as trigger type
13. write the event name from step 3 as the event name, in our case it’s

myevent

14. chose that it triggers on Some Custom Events
15. Choose the variable we set up earlier

GA - WP Result

Contains

success

16. Save
17. Go to tags and create a NEW tag, choose Universal Analytics Google Analytics as Tag type, Track Type: Event,

Category: My Event,
 Action: clickedMyEvent,
 Label: clickedMyEvent,
 Value: 1

18. Under Google Analytics Settings, click on new variable, and add your Tracking ID for your GA container.
19. Click on “choose a trigger” and choose

GA - myEvent Conversion

that we created earlier.
20. Save.
21. PUBLISH
22. Verify it get triggered in GA.
23. Set up a Goal in GA
-> Admin -> Goals -> News -> Custom -> Name it MyEvent Result-> Choose Event as type ->
then fill in the same information that we put in GTM earlier, EXCEPT VALUE that should be 0:

 Category: My Event,
 Action:clickedMyEvent,
 Label: clickedMyEvent,
 Greater than: 0

24.Save
25. Verify in real time analytics that it’s working!

Add your comment