简体   繁体   中英

Modify Google Analytics custom dimensions on the go

I'm very new to analytics management and I'm stuck on a little problem: I'd simply like to know if the visitor has scrolled on the page and/or dragged an element. Two simple booleans that are linked to the session (not the user).

I created two custom dimensions in GA's admin panel, userHasScrolled and userHasDragged, both with a Session lifespan.

As it seems you can't define a default value for custom dimensions, I set both dimensions to false along with the pageview call:

ga('set', {
  'dimension1': 'false', // userHasScrolled
  'dimension2': 'false'  // userHasDragged
});

However, I'd like to modify them once the user as scrolled/dragged. According to the doc, you can't modify them without sending a new pageview, which doesn't suit me as the user might not have gone to another page at all.

What's the best way of handling it? Thanks!

Custom dimensions and metrics can also be updated with event hits. You can send an event when the user has completed either or both actions, and when you do send those events you can update the custom dimensions at that time.

Code example:

ga('send','event','your category', 'your action', 'your label', {'dimension1': 'true', 'dimension2': 'false'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM