I want to track user interactions by using mixpanel. It provides JSON APIs that I can call successfully if I encode the request in base64. This requires a little bit of JS code I added as JS asset.
What I would like to do is to have a simple function log() that I can call whenever I wants.
At the moment I can do that within one page where I added a service call MX_track and I trigger it with MX_track.execute({});
Unfortunately I can not add the same service with the same name to another page, hence I cannot use the JS function log() over multiple pages.
In theory if a service only needs to access localStorage it should be possible to be triggered anywhere regardless if it is added to a page or not. I tried to create a template, but the service does not propagate to the child pages.
Is there any other way?