You likely want to be able to pass some tracking information about the visitors to your Magento site through to your back-end systems. I usually implement tracking using the same method as Google Analytics, just for convenience. Also, there is a ready-made URL Builder for clients non-google campaigns. This sends tracking data through to the site but you need a custom module to read those parameters and store them in a cookie. Your order export module can then read the cookie and include that information with the order.

You can intercept a Magento event that is called at the start of every request using this config.xml…


And then in the method you specify you can…

public function interceptMethodNameCanBeAnything($observer) {
    $request = $observer->getEvent()->getData('front')->getRequest();
    $utm_source = $request->utm_source;

    //do whatever you want with your variable here

2 thoughts on “Read URL parameters inside Magento (for tracking)

  1. Big follower on this blog, loads of your articles or blog posts have definitely helped me out. Looking forward to updates!

  2. $request = $observer->getEvent()->getData(‘front’)->getRequest();
    $utm_source = $request->utm_source;
    i have used into my observer but shown following error
    “Call to a member function getRequest() on a non-object”
    need your helps more….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>