Is there any way for Google Analytics to track multiple event parameters like Mixpanel?

后端 未结 4 897
[愿得一人]
[愿得一人] 2020-12-31 14:14

Given:

_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

I tried with opt_label but it seems like it\'s just a string

相关标签:
4条回答
  • 2020-12-31 14:23

    GA is not as good as Mixpanel for tracking event (or hit in general) properties, and maybe you should rethink what you want to/can do in GA. That said, there is a way to achieve what you need with custom dimensions and metrics. Here is some info on what they do, and here are instructions on how to set them up in the admin panel, and here you can find how to use them in your code. Some limitations:

    There are 20 indices available for different custom dimensions and 20 indices for custom metrics in each property. 360 accounts have 200 indices available for custom dimensions and 200 for custom metrics.

    Custom dimensions cannot be deleted, but you can disable them.

    First, you would need to add the custom dimensions/metrics through the admin panel in GA (Admin -> Properties column -> Custom Definitions -> Custom Dimensions/Metrics).

    Using analytics.js, you can set the event properties using either set before you trigger a hit, or send when you trigger a hit. Examples:

    // set the dimension/metric values before the hit
    ga('set', {
      'dimension5': 'custom dimension data',
      'metric5': 8000
    });
    // values set above are passed to GA along with the hit info
    ga('send', 'event', 'someCategory', 'someAction');
    
    
    // or alternatively
    ga('send', 'event', 'someCategory', 'someAction', {
      'dimension5': 'custom dimension data',
      'metric5': 8000
    });
    

    In case you're not sure what's the difference between dimensions and metrics, check this out.

    I hope this helps

    0 讨论(0)
  • 2020-12-31 14:25

    I'm not sure what mixpanel is, so I'm unaware of what you're trying to compare analytics to. If you provided a specific example of the data you're trying to collect, I could provide you with a better answer.

    Lets say you have a video player and you want to track how long people watch the video and how many times people paused the video, you would do something like this;

    if (video == "pause") {
       var playTime = playduration(), // Total minutes of video watched
           clickPause = pauseNum(); // Total number of times video was paused
    
       _gaq.push(['_trackEvent', 'Video', 'Play', playTime]);
       _gaq.push(['_trackEvent', 'Video', 'Pause', clickPause]);
    }
    

    Obviously this is generic, but as you can see in the _gaq.push arrays, Play and Pause are the parameters and playTime and clickPause are the variable values of the parameters.

    0 讨论(0)
  • 2020-12-31 14:29

    The label is optional, so I would expand it to something like:

    <a href="#" onClick="_gaq.push(['_trackEvent', 'Games', 'Play', 'Tetris']);">Play</a>
    

    Category = 'Games'
    Event = 'Play'
    Label = 'Tetris'

    0 讨论(0)
  • 2020-12-31 14:36

    While you can certainly make this work in Google Analytics, other analytics services like Mixpanel, KISSmetrics, Kontagent, etc specialize in event analysis and give you more flexibility. Having said that, you can hack the Google Analytics event model to get what you’re looking for.

    If you want to track multiple parameters for each event in Google Analytics I’d suggest cramming the parameters you want to track into the event label. This is workable for two reasons: Event labels can be really long (ridiculously long, actually) and Google Analytics provides flexible filtering and segmentation options.

    So, to extend an example discussed in an earlier answer, you could have an event for tracking video play details that looks like this:

    _gaq.push(['_trackEvent', 'Videos', 'Play', 'title:MoreCatLolz, 
        percentPlayed:63, adShown:true, res:480p, fullScreen:false']);
    

    All we've done is toss a few arbitrary parameters into the event label string in such a way that we can pull them out later. To analyze the results you could filter your event reports to show, say, the number of times the ‘MoreCatLolz’ video was shown with ads:

    Number of times MoreCatLolz was shown with ads

    Alternately, using advanced segments and regex, you could count the number of visits in which users watched at least 90% of any video:

    Number of visits in which users watched at least 90% of any video

    To track persistent user data, such as name, join date, level, purchase count, etc., I’d suggest using visitor-level custom variables which are automatically included with every tracking call (including events) and allow you to apply many of the same analysis techniques.

    0 讨论(0)
提交回复
热议问题