ipunkt / laravel-analytics

Analytics tracking package for Laravel
MIT License
263 stars 54 forks source link

Way to track API requests #51

Closed imrealashu closed 5 years ago

imrealashu commented 6 years ago

I've been trying to track events for API requests e.g., Analytics::trackEvent('Search', 'Filter', 'city') but not able to send it to GA since the method isn't rendering the page, just JSON response. Is there any way to do that? Any suggestions would help.

Grayda commented 5 years ago

I had this exact same issue and my solution was to use this Laravel library for Google Analytics' Measurement Protocol which is designed for situations like this.

Because I was using a trait to abstract out all my analytics, replacing this library with the new one was easy.

rokde commented 5 years ago

@Grayda Thank you for your advice. Maybe @imrealashu can use this too. We had no problems yet with our library - but we also built it. :)

imrealashu commented 5 years ago

Thanks for the advice @Grayda I used Vue Analytics for the time being to track events on the Vue Components. But Laravel Gamp looks cool I'll definitely try this out and try to go with your suggestion. Thanks for the suggestion.