I have a website where users can add products to favorites. I want to track how many user are using this feature, and later be able to access this information to see how this feature is performing using Google Analytics Api.

So I will create an event to track this when a user clicks on the button.

ga('send', {
  hitType: 'event',
  eventCategory: 'Products',
  eventAction: 'click',
  eventLabel: 'favorite'

Then to see how many favorites has a product received, I will have to filter how many events have been fired in the product url.

The problem, is:

  • If a user clicks the add to favorites button in a list of products the event is not fired in the product url, so it will not count into the product events.
  • If in the product page, I add related products, each one with its own button. The related products likes would count in the main product, as they are fired in the product page url.

How would you approach this? Maybe I could add the product id in the eventLabel and change the eventAction to "click-favorite", but I feel that this is not the corret solution.

Thank you.

  • To track events in the past, I've loaded an invisible iframe without an src. When a button is clicked, I attach an onclick iframe src="buttonid", and on the buttonid page I attach an analytics tracker. It logs the page url in the behavior tab so that I can see which buttons have been clicked. I'm sure there's got to be a better way to do this, but this is the way that I did it. – Michael d Mar 7 '18 at 16:39
  • Thanks michael, the solution is too tricky, I would like to see if there is a less tricky solution. Thanks – David Rojo Mar 8 '18 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.