📊 Google Analytics
Tracking user interaction
Sometimes, it's good to track not only web page view, but other user interactions such as button clicks. This is especially important in Single Page Applications (SPA) as they often do not have traditional pages, but dynamic content.
This is useful for tracking dynamic parts of SPA such as tabs, collapsible content or sliders (carousels). To track such part of an app add following line of code to
onClick event of element that triggers the corresponding content.
ga('set', 'page', page); // Set virtual page ga('send', 'pageview'); // Send it to GA
Events are good for tracking interactive elements such as buttons, links, etc, that do not redirect to other subpages.
ga('send', 'event', 'Homepage', 'Slider', 'Slide left');