title: Google Analytics - Angular 2 - events contain undefined values
body: <p>I try to send custom events from an angular 2 app to google analytics</p>
  
  <p>here is the code</p>
  
  <pre><code>ga('send', 'event', {
      eventCategory: eventCategory,
      eventLabel: eventLabel,
      eventAction: eventAction,
      eventValue: eventValue
  });
  </code></pre>
  
  <p>here is how I call it :</p>
  
  <pre><code>this.googleAnalyticsService.sendEvent("testCategory", "testAction", "testLabel", 10);
  </code></pre>
  
  <p>checking the real time view, in the "Events" tab, I see all the events "Event Category" &amp; "Event Action" are "undefined"</p>
  
  <p>I tried to edit the "Google Analytics" tag in Tag Manager and set </p>
  
  <pre><code>"category" field to "eventCategory"
  "label" field to "eventLabel"
  "action" field to "eventAction"
  "value" field to "eventValue"
  </code></pre>
  
  <p>but with no luck, can someone help me out? </p>
  
  <p>[edit]</p>
  
  <p>the event is actually not fired at all unless I set values in the tag itself
  but how do I get actual values sent from my code ???</p>
  
  <p><a href="https://i.stack.imgur.com/yxbR6.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>here are the GA debugger logs :
  apparently GA sends an event with "undefined" fields</p>
  
  <p>my own ga.send is sent too, so I dont know why this one does not trigger</p>
  
  <pre><code>Initializing Google Analytics.
  analytics_debug.js:10 Running command: ga("create", "UA-********-3", {name: "gtm4"})
  analytics_debug.js:10 Creating new tracker: gtm4
  analytics_debug.js:10 Running command: ga("gtm4.set", "&amp;gtm", "G9452W68FS")
  analytics_debug.js:10 Running command: ga("gtm4.set", "nonInteraction", false)
  analytics_debug.js:10 Running command: ga("gtm4.set", "hitCallback", [function])
  analytics_debug.js:10 Running command: ga("gtm4.send", {hitType: "event", eventCategory: "undefined", eventAction: "undefined", eventLabel: undefined, eventValue: undefined})
  analytics_debug.js:10 Setting throttling cookie: "_gat_UA-********-3"
  analytics_debug.js:10 
  Sent beacon:
  v=1&amp;_v=j68d&amp;a=708558753&amp;t=event&amp;ni=0&amp;_s=1&amp;dl=https%3A%2F%2F*******************%2Fa%2Fgifts%3Fs%3D**************************************%26pid%3D14%26m%3D0%26categories%3D%26p%3D0&amp;ul=fr-fr&amp;de=UTF-8&amp;sd=24-bit&amp;sr=1920x1080&amp;vp=1903x943&amp;je=0&amp;ec=undefined&amp;ea=undefined&amp;_u=QAGAAAAB~&amp;jid=1225520003&amp;gjid=48267034&amp;cid=804438810.1535016930&amp;tid=UA-********-3&amp;_gid=121630742.1536576429&amp;_r=1&amp;gtm=G9452W68FS&amp;z=461818314
  
  analytics_debug.js:10 &lt;unknown&gt;        (&amp;gtm)  G9452W68FS
  analytics_debug.js:10 _j1              (&amp;jid)  1225520003
  analytics_debug.js:10 _j2              (&amp;gjid) 48267034
  analytics_debug.js:10 adSenseId        (&amp;a)    708558753
  analytics_debug.js:10 apiVersion       (&amp;v)    1
  analytics_debug.js:10 clientId         (&amp;cid)  804438810.1535016930
  analytics_debug.js:10 encoding         (&amp;de)   UTF-8
  analytics_debug.js:10 eventAction      (&amp;ea)   undefined
  analytics_debug.js:10 eventCategory    (&amp;ec)   undefined
  analytics_debug.js:10 hitType          (&amp;t)    event
  analytics_debug.js:10 javaEnabled      (&amp;je)   0
  analytics_debug.js:10 language         (&amp;ul)   fr-fr
  analytics_debug.js:10 location         (&amp;dl)   https://*******************/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0
  analytics_debug.js:10 nonInteraction   (&amp;ni)   0
  analytics_debug.js:10 screenColors     (&amp;sd)   24-bit
  analytics_debug.js:10 screenResolution (&amp;sr)   1920x1080
  analytics_debug.js:10 trackingId       (&amp;tid)  UA-********-3
  analytics_debug.js:10 viewportSize     (&amp;vp)   1903x943
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("set", "page", "/a/gifts?s=**************************************&amp;pid=14&amp;m=0&amp;categories=&amp;p=0")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Running command: ga("send", "pageview")
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  analytics_debug.js:10 Registered new plugin: ga(provide, "render", Function)
  main.79214c40a0c056e8e45c.106.32125.bundle.js:1 sending to ga Product Details Page Page Displayed Sports &amp; Loisirs 14
  analytics_debug.js:10 Executing Google Analytics commands.
  analytics_debug.js:10 Running command: ga("send", "event", {eventCategory: "Product Details Page", eventLabel: "Sports &amp; Loisirs", eventAction: "Page Displayed", eventValue: 14})
  analytics_debug.js:10 Command ignored. Unknown target: undefined
  </code></pre>
  
  <p>thanks</p>