DEV Community

Ilkka
Ilkka

Posted on

How to get source, medium, campaign etc. from each page visit, like Google Analytics does it?

You sometimes need to know how you got each individual customer to your web site. Using Google Analytics, you only know at an aggregate level. You can analyze things inside Google Analytics, but you can't take that information out.

For example. Let's say your users can sign up to a product and maybe start paying for it? Maybe it's a subscription product, where lifetime values need to be observed over long periods of time. Google Analytics doesn't help with that, since it is designed for transactional, webshop-like businesses.

Well, you're in luck. I have just the thing you need.

I've created a library called VisitDataJS that emulates the behavior of Google Analytics and provides the same dimensions for each visitor:

  • medium
  • source
  • campaign
  • content
  • term

The library is already quite popular, getting between 5M-7M page loads every day. But for some reason, the github repo is not very active. So I'm looking for more active users, feedback.

Head over to https://github.com/ilkkapeltola/visitdata and check it out.

Top comments (0)