2

Google sends parameters like utm_source, utm_campaign, etc ... I would like to know how I get these parameters in magento because I would like to add a custom condition in price rules, check if utm_source is = partner if yes, apply discount.

2

I dont know how he is your URL and that parameters ! in Magento standard URL's are formated like this: http://domain.com/rooter/controllerName/actionMethod.

  1. If your URL is like this: http://domain.com/path/index/id/bling/123456, you can get the bling paramater as follow: $this->getRequest()->getParam('bling') //you get 123456.

  2. If your Url is like this: http://domain.com/index?bling=123456, you get the bling parametrer as follow: $_GET['bling'] // you get 123456.

  3. You can get all the params in array like this: $this->getRequest()->getParams().

Once you have you parameter, you can do some conditions to apply your disount.

Exemple:

if ( $this->getRequest()->getParam('utm_source') == 'partner' ){
    //your discount here
}

if ( $_GET['utm_source'] == 'partner' ){
    //your discount here
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.