English subtitles

← Sending Events to Tag Manager Quiz

Get Embed Code
4 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. Now that we've got the daily
    special working in our app,
  2. we can use Google Analytics
    to to see how people use it.
  3. For the Show Daily sSpecial activity,
  4. we'll send our tracking
    data to Tag Manager.
  5. And then Tag Manager will
    forward it to Google Analytics.
  6. You already saw that you can put data
    into the dataLayer using the push
  7. method, specifying the key and
    the value.
  8. When we used it, the push values into
    the dataLayer, keyed by food pref.
  9. In this case vegan is a value,
    food pref is the key.
  10. Put an event in the dataLayer
    is very similar.
  11. You can call dataLayer.push,
    specifying event as the key.
  12. And then you'll need to
    pass a bunch of other stuff
  13. to pass the parameters for the event.
  14. In this case the key absolutely
    must be exactly "event," however,
  15. it's easier to use
    the pushEvent method instead.
  16. This method makes it easier to
    pass parameters for the event.
  17. You need to pass the eventName, and
  18. you pass extra data using the mapOf
    method, specifying key value pairs.
  19. Now, each of these keys corresponds to
    a dataLayer variable in Tag Manager.
  20. Let's see what this means
    in practical terms.
  21. In the code for our app,
    in the main activity,
  22. in the method that gets called
    to show the daily special,
  23. we can add the code to put in
    an event in the dataLayer.
  24. Get the dataLayer and
    push an event onto it.
  25. In this case, we're pushing the event
    open screen and we're setting
  26. Show Daily Special as the value of
    the screen name key, and this means
  27. that the screen-name dataLayer variable
    will get the value, Show Daily Special.
  28. So, go ahead and add the code to your
    app to push an event into the dataLayer
  29. when the user clicks
    the Show Daily Special button.
  30. In Main Activity you're going to update
    the method startShowDailySpecialActivity
  31. to push the openScreen event
    into the dataLayer, and
  32. you need to set the value
    of the screen-name kry.
  33. You'll create the new screen-name
    dataLayer variable in tag manager
  34. in the next section.