I'm implementing Facebook Conversion Tracking code. I've been instructed to insert the Facebook surveillance JavaScript onto the newsletter subscription confirmation page. But on the website, there is no "confirmation page", just a confirmation message that Magento displays in the header of the home page upon successful confirmation (which I've found is displayed using addSuccess() in code/core/Mage/Newsletter/controllers/SubscriberController.php).
To insert the same code on the purchase confirmation page, I've been able to able Anaraky's GPL-licensed GDRT extension, which creates a Block and uses $this->getData('pageType')
on a class that extends Mage_Core_Block_Abstract to only insert the block on the desired page.
e.g. in a custom module, app/code/local/Alleyne/FCT/Block/Script.php
class Alleyne_FCT_Block_Script extends Mage_Core_Block_Abstract {
// [snip]
protected function _toHtml() {
$type = $this->getData('pageType');
if ($type == 'purchase') {
// return JavaScript...
}
// [snip]
}
But for the newsletter confirmation, I can't just filter by page type -- I only want to trigger it when the newsletter subscription action is taking place (which happens to be on the home page).
Do I need to override Mage_Newsletter_SubscriberController::confirmAction() to output the desire JavaScript? If so, how? If not, what's a more reasonable approach?