DEV Community

Discussion on: Using Google Analytics with Angular

Collapse
 
bgadrian profile image
Adrian B.G.

Nice example.

As a bonus do NOT implement GA or any other analytics directly in your business logic, always make a relay (abstract class, event system, pub/sub, anything) and encapsulate your tracking there. In 100% of production projects I saw this problem.

The magic rule: "when you want to add a new tracking system there should be only 1 part of the code that will be modified". Keeping the "1 reason to change" rule.

Even if you use a service like segment you may realize that is too expensive and want to switch to other one.