Advertisement
Guest User

Bruno Alexandre

a guest
Jul 6th, 2010
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.85 KB | None | 0 0
  1.   // This file is part of the Magento Article, How to Add Tracking Links to Magento
  2.   // Please change the default newAction() method with the code below, changing it to your own needs
  3.  
  4.     public function newAction()
  5.     {
  6.         if ($this->getRequest()->isPost() && $this->getRequest()->getPost('email')) {
  7.             $session   = Mage::getSingleton('core/session');
  8.             $email     = (string) $this->getRequest()->getPost('email');
  9.            
  10.             /*
  11.             *
  12.             *  OpenX image beacon tracker code
  13.             *  - Generated with OpenX v2.8.2-rc25
  14.             *
  15.             *  If this tag is being served on a secure (SSL) page, you must replace
  16.             *  'http://d1.openx.org/...'
  17.             * with
  18.             *  'https://d1.openx.org/...'
  19.             *
  20.             *  To help prevent caching of this tracker beacon, if possible,
  21.             *  Replace %%RANDOM_NUMBER%% with a randomly generated number (or timestamp)
  22.             *
  23.             *  In order for the adserver to track variables for this conversion,
  24.             *  they must be provided by the client.
  25.             *
  26.             *  Additional variables may be added, however they must be added
  27.             *  in the adserver as well before they will be logged.
  28.             *
  29.             *  The '%%VARIABLE_VALUE%%' should be replaced with the
  30.             *  actual values for this sale.
  31.             *
  32.             */
  33.             $timestamp    = time();
  34.             $openXtracker = "<div id='m3_tracker_1828' style='position: absolute; left: 0px; top: 0px; visibility: hidden;'><img src='http://d1.openx.org/ti.php?trackerid=1828&amp;email=$email&amp;cb=$timestamp' width='0' height='0' alt='' /></div>";
  35.                            
  36.             // EuroAds Tracking code
  37.             $euroadsTracker = "<iframe src='http://www.euroads.dk/system/showtrackingpixels.php?cpid=2125&sid=1&orderid=$email&pgid=96' width='1' height='1' marginwidth='0' marginheight='0' allowtransparency='true' frameborder='0' scrolling='no' hspace='0' vspace='0'></iframe>";
  38.            
  39.                
  40.             try {
  41.                 if (!Zend_Validate::is($email, 'EmailAddress')) {
  42.                     Mage::throwException($this->__('Please enter a valid email address'));
  43.                 }
  44.  
  45.                 $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
  46.                 if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE) {
  47.                     $session->addSuccess($this->__('Confirmation request has been sent') . $openXtracker . $euroadsTracker);
  48.                 }
  49.                 else {
  50.                     $session->addSuccess($this->__('Thank you for your subscription') . $openXtracker . $euroadsTracker);
  51.                 }
  52.                
  53.             }
  54.             catch (Mage_Core_Exception $e) {
  55.                 $session->addException($e, $this->__('There was a problem with the subscription: %s', $e->getMessage()));
  56.             }
  57.             catch (Exception $e) {
  58.                 $session->addException($e, $this->__('There was a problem with the subscription'));
  59.             }
  60.         }
  61.         $this->_redirectReferer();
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement