Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add newsletter subscribe as conversion option #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/code/community/THB/ABTest/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ public function conversion_wishlist_add_product($observer)
}
}

/**
* Registers a conversion when a visitor subscribes to the newsletter
*
*/
public function conversion_newsletter_subscribe($observer)
{
# This runs every time a visitor subscribes, regardless of whether or not
# an AB test is running.
if ( ! Mage::helper('abtest')->isRunning())
return;

if ($variations = Mage::helper('abtest/visitor')->getVariationsFromObserver($observer->getEvent()->getName(), 'observer_conversion'))
{
foreach ($variations as $variation)
{
# Get our table name for variations and update the row information
$this->_register_conversion($variation, 0); // send 0 price value for conversion
}
}
}

/**
* Registers a conversion when a product is sent to a friend
*
Expand Down
10 changes: 10 additions & 0 deletions app/code/community/THB/ABTest/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@
</observers>
</wishlist_add_product>

<newsletter_subscriber_save_commit_after>
<observers>
<abtest>
<type>singleton</type>
<class>abtest/observer</class>
<method>conversion_newsletter_subscribe</method>
</abtest>
</observers>
</newsletter_subscriber_save_commit_after>

<sendfriend_product>
<observers>
<abtest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<optgroup label="Action">
<option <?php if ($this->getTest()->getObserverConversion() == "checkout_cart_add_product_complete") echo 'selected="selected"'; ?>value="checkout_cart_add_product_complete">Added product to cart</option>
<option <?php if ($this->getTest()->getObserverConversion() == "wishlist_add_product") echo 'selected="selected"'; ?>value="wishlist_add_product">Added product to wishlist</option>
<option <?php if ($this->getTest()->getObserverConversion() == "newsletter_subscriber_save_commit_after") echo 'selected="selected"'; ?>value="newsletter_subscriber_save_commit_after">Visitor Subscribed to newsletter</option>
<option <?php if ($this->getTest()->getObserverConversion() == "checkout_onepage_controller_success_action") echo 'selected="selected"'; ?>value="checkout_onepage_controller_success_action">Completed checkout (purchased via one-page checkout)</option>
<option <?php if ($this->getTest()->getObserverConversion() == "sendfriend_product") echo 'selected="selected"'; ?>value="sendfriend_product">Sent product to friend</option>
</optgroup>
Expand Down