diff --git a/Block/Script.php b/Block/Script.php
new file mode 100644
index 0000000..bf0363d
--- /dev/null
+++ b/Block/Script.php
@@ -0,0 +1,413 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Block;
+
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Checkout\Model\Cart;
+use Magento\Customer\Model\Group as CustomerGroup;
+use Magento\Checkout\Model\Session\Proxy as CheckoutSession;
+use Magento\Customer\Model\Session\Proxy as CustomerSession;
+use Magento\Framework\Registry;
+use Magento\Framework\View\Element\Template\Context;
+use Magento\Sales\Model\Order;
+use Magento\Sales\Model\ResourceModel\Sale\Collection as SaleCollection;
+use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
+use Magento\Wishlist\Controller\WishlistProviderInterface;
+use Woopra\Analytics\Helper\Data;
+
+class Script extends \Magento\Framework\View\Element\Template
+{
+ private $checkoutCart;
+ public $checkoutSession;
+ private $context;
+ private $customerGroup;
+ private $customerSession;
+ private $dataHelper;
+ public $escaper;
+ public $order;
+ public $productRepository;
+ private $registry;
+ private $saleCollection;
+ private $salesOrderCollection;
+ private $wishlistProvider;
+
+ public function __construct(
+ Context $context,
+ Cart $checkoutCart,
+ CheckoutSession $checkoutSession,
+ CollectionFactory $salesOrderCollection,
+ CustomerGroup $customerGroup,
+ CustomerSession $customerSession,
+ Data $dataHelper,
+ Order $order,
+ ProductRepository $productRepository,
+ Registry $registry,
+ SaleCollection $saleCollection,
+ WishlistProviderInterface $wishlistProvider,
+ array $data = []
+ ) {
+ $this->cart = $checkoutCart;
+ $this->checkoutSession = $checkoutSession;
+ $this->customerGroup = $customerGroup;
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->escaper = $context->getEscaper();
+ $this->order = $order;
+ $this->productRepository = $productRepository;
+ $this->registry = $registry;
+ $this->saleCollection = $saleCollection;
+ $this->salesOrderCollection = $salesOrderCollection;
+ $this->wishlistProvider = $wishlistProvider;
+
+ parent::__construct($context, $data);
+ }
+
+ public function getSetting($key = null)
+ {
+ static $data;
+ if (empty($data)) {
+ $data = [
+ 'enabled' => $this->dataHelper->getEnabled(),
+ 'test' => $this->dataHelper->getTest(),
+ 'visitor_timeout' => $this->dataHelper->getVistorTimeout(),
+ 'track_url_parameters' => $this->dataHelper->getTrackUrlParameters(),
+ 'hostname' => $this->dataHelper->getHostname(),
+ 'subdomain' => $this->dataHelper->getSubdomain(),
+ 'tracking_cookie_expiration' => $this->dataHelper->getTrackingCookieExpiration(),
+ 'tracking_cookie_name' => $this->dataHelper->getTrackingCookieName(),
+ 'tracking_cookie_domain' => $this->dataHelper->getTrackingCookieDomain(),
+ 'tracking_cookie_path' => $this->dataHelper->getTrackingCookiePath(),
+ 'ping' => $this->dataHelper->getPing(),
+ 'ping_interval' => $this->dataHelper->getPingInterval(),
+ 'download_tracking' => $this->dataHelper->getDownloadTracking(),
+ 'download_tracking_pause' => $this->dataHelper->getDownloadTrackingPause(),
+ 'outgoing_tracking' => $this->dataHelper->getOutgoingTracking(),
+ 'outgoing_tracking_pause' => $this->dataHelper->getOutgoingTrackingPause(),
+ 'outgoing_ignore_subdomain' => $this->dataHelper->getOutgoingIgnoreSubdomain(),
+ 'hide_campaign' => $this->dataHelper->getHideCampaign(),
+ 'customer_name_output' => $this->dataHelper->getCustomerName(),
+ 'customer_email_output' => $this->dataHelper->getCustomerEmail(),
+ 'customer_company_output' => $this->dataHelper->getCustomerCompany(),
+ 'customer_location_output' => $this->dataHelper->getCustomerLocation(),
+ 'customer_phone_output' => $this->dataHelper->getCustomerPhone(),
+ 'customer_group_output' => $this->dataHelper->getCustomerGroup(),
+ 'customer_lifetime_sales_output' => $this->dataHelper->getCustomerLifetimeSales(),
+ 'customer_number_orders_output' => $this->dataHelper->getCustomerNumberOrders(),
+ 'customer_create_date_output' => $this->dataHelper->getCustomerCreateDate(),
+ 'customer_cart_items_output' => $this->dataHelper->getCustomerCartItems(),
+ 'customer_cart_total_output' => $this->dataHelper->getCustomerCartTotal(),
+ 'customer_wishlist_items_output' => $this->dataHelper->getCustomerWishlistItems(),
+ 'customer_wishlist_total_output' => $this->dataHelper->getCustomerWishlistTotal()
+ ];
+
+ $customer = $this->customerSession->getCustomer();
+ if (!empty($customer)) {
+ if ($customer->getName() != ' ' && $this->dataHelper->getCustomerName() != null) {
+ $data['customer_name'] = $this->_escaper->escapeQuote($customer->getName());
+ }
+ if ($this->dataHelper->getCustomerEmail() != null) {
+ $data['customer_email'] = $customer->getEmail();
+ }
+
+ $address = $customer->getDefaultBillingAddress();
+ if (!empty($address)) {
+ $address = $customer->getDefaultShippingAddress();
+ }
+ if (!empty($address)) {
+ if ($this->dataHelper->getCustomerCompany() != null) {
+ $data['customer_company'] = $this->_escaper->escapeQuote($address->getCompany());
+ }
+ if ($this->dataHelper->getCustomerLocation() != null) {
+ $data['customer_location'] =
+ $this->_escaper->escapeQuote($address->getCity()) . ', ' .
+ $this->_escaper->escapeQuote($address->getRegion()) .
+ ' (' . $address->getCountryId() . ')';
+ }
+ if ($this->dataHelper->getCustomerPhone() != null) {
+ $data['customer_phone'] = $this->_escaper->escapeQuote($address->getTelephone());
+ }
+ }
+
+ if ($this->dataHelper->getCustomerGroup() != null) {
+ $groupId = $this->customerSession->getCustomerGroupId();
+ $this->customerGroup->load($groupId);
+ $group = $this->customerGroup->getCode();
+ $data['customer_group'] = $this->_escaper->escapeQuote($group);
+ }
+
+ if ($this->dataHelper->getCustomerCreateDate() != null) {
+ $date = $customer->getCreatedAtTimestamp();
+ if ($date != 0) {
+ $data['customer_create_date'] = $this->_escaper->escapeQuote(date('m-d-Y H:i', $date));
+ }
+ }
+
+ $customerTotals = $this->saleCollection
+ ->setOrderStateFilter(\Magento\Sales\Model\Order::STATE_CANCELED, true)
+ ->setCustomerIdFilter($customer->getId())
+ ->load()
+ ->getTotals();
+ if ($this->dataHelper->getCustomerLifetimeSales() != null && $group != 'NOT LOGGED IN') {
+ $data['customer_lifetime_sales'] = round($customerTotals->getLifetime(), 2);
+ }
+ if ($this->dataHelper->getCustomerNumberOrders() != null && $group != 'NOT LOGGED IN') {
+ $data['customer_number_orders'] = $customerTotals->getNumOrders();
+ }
+
+ $wishListCollection = $this->wishlistProvider->getWishlist()->getItemCollection();
+ $wishlistItems = 0;
+ $wishListTotal = 0;
+ foreach ($wishListCollection as $item) {
+ $product = $item->getProduct();
+ $wishlistItems = $wishlistItems ++;
+ $wishListTotal = $wishListTotal + $product->getPrice();
+ }
+ if ($this->dataHelper->getCustomerWishlistItems() != null) {
+ $data['customer_wishlist_items'] = $wishlistItems;
+ }
+ if ($this->dataHelper->getCustomerWishlistTotal() != null) {
+ $data['customer_wishlist_total'] = $wishListTotal;
+ }
+ }
+
+ if ($this->dataHelper->getCustomerCartItems() != null) {
+ $data['customer_cart_items'] = $this->cart->getQuote()->getItemsCount();
+ }
+ if ($this->dataHelper->getCustomerCartTotal() != null) {
+ $data['customer_cart_total'] = round($this->cart->getQuote()->getGrandTotal(), 2);
+ }
+ $currentCategory = $this->registry->registry('current_category');
+ if (!empty($currentCategory)) {
+ $data['category'] = $this->_escaper->escapeQuote($currentCategory->getName());
+ }
+ $currentProduct = $this->registry->registry('currentProduct');
+ if (!empty($currentProduct)) {
+ $data['product_sku'] = $this->_escaper->escapeQuote($currentProduct->getSku());
+ $data['product_price'] = strip_tags($currentProduct->getPrice());
+ }
+
+ if ($this->dataHelper->getNewsletterSubscribed() != null) {
+ $data['woopra_subscriber_changed'] = $this->customerSession
+ ->getData('woopra_subscriber_changed', true);
+ $data['woopra_subscriber_status'] = $this->customerSession
+ ->getData('woopra_subscriber_status', true);
+ $data['woopra_subscriber_email'] = $this->customerSession
+ ->getData('woopra_subscriber_email', true);
+ }
+
+ if ($this->dataHelper->getContactFormSent() != null) {
+ $data['woopra_contacts_index_post'] = $this->customerSession
+ ->getData('woopra_contacts_index_post', true);
+ $data['woopra_contacts_name'] = $this->customerSession
+ ->getData('woopra_contacts_name', true);
+ $data['woopra_contacts_email'] = $this->customerSession
+ ->getData('woopra_contacts_email', true);
+ $data['woopra_contacts_telephone'] = $this->customerSession
+ ->getData('woopra_contacts_telephone', true);
+ $data['woopra_contacts_comment'] = $this->customerSession
+ ->getData('woopra_contacts_comment', true);
+ }
+
+ $data['woopra_cart_wishlist_trigger'] = $this->customerSession
+ ->getData('woopra_cart_wishlist_trigger', true);
+ $data['woopra_cart_wishlist_status'] = $this->customerSession
+ ->getData('woopra_cart_wishlist_status', true);
+ $data['woopra_cart_wishlist_name'] = $this->customerSession
+ ->getData('woopra_cart_wishlist_name', true);
+ $data['woopra_cart_wishlist_sku'] = $this->customerSession
+ ->getData('woopra_cart_wishlist_sku', true);
+ $data['woopra_cart_wishlist_price'] = $this->customerSession
+ ->getData('woopra_cart_wishlist_price', true);
+
+ if ($this->dataHelper->getCatalogSearch() != null) {
+ $data['woopra_search_name'] = $this->dataHelper->getCatalogSearch();
+ $data['woopra_search_trigger'] = $this->customerSession
+ ->getData('woopra_search_trigger', true);
+ $data['woopra_search_keywords'] = $this->customerSession
+ ->getData('woopra_search_keywords', true);
+ }
+
+ if ($this->dataHelper->getCustomerCreateAccount() != null) {
+ $data['woopra_create_account_trigger'] = $this->customerSession
+ ->getData('woopra_create_account_trigger', true);
+ }
+
+ if ($this->dataHelper->getCustomerCreateAccountSuccess() != null) {
+ $data['woopra_create_account_success_trigger'] = $this->customerSession
+ ->getData('woopra_create_account_success_trigger', true);
+ }
+
+ if ($this->dataHelper->getCheckoutBillingAddress() != null) {
+ $data['woopra_checkout_trigger'] = $this->customerSession
+ ->getData('woopra_checkout_trigger', true);
+ }
+
+ if ($this->dataHelper->getCheckoutSuccess() != null) {
+ $data['woopra_checkout_payment_method'] = $this->customerSession
+ ->getData('woopra_checkout_payment_method', true);
+ $data['woopra_checkout_payment_cc_type'] = $this->customerSession
+ ->getData('woopra_checkout_payment_cc_type', true);
+ $data['woopra_checkout_success_trigger'] = $this->customerSession
+ ->getData('woopra_checkout_success_trigger', true);
+ $data['woopra_checkout_success_coupon_code'] = $this->customerSession
+ ->getData('woopra_checkout_success_coupon_code', true);
+ $data['woopra_checkout_success_discount_amount'] = $this->customerSession
+ ->getData('woopra_checkout_success_discount_amount', true);
+ $data['woopra_checkout_success_order_id'] = $this->customerSession
+ ->getData('woopra_checkout_success_order_id', true);
+ $data['woopra_checkout_success_order_subtotal'] = $this->customerSession
+ ->getData('woopra_checkout_success_order_subtotal', true);
+ $data['woopra_checkout_success_order_total'] = $this->customerSession
+ ->getData('woopra_checkout_success_order_total', true);
+ $data['woopra_checkout_success_order_weight'] = $this->customerSession
+ ->getData('woopra_checkout_success_order_weight', true);
+ $data['woopra_checkout_success_shipping_amount'] = $this->customerSession
+ ->getData('woopra_checkout_success_shipping_amount', true);
+ $data['woopra_checkout_success_shipping_description'] = $this->customerSession
+ ->getData('woopra_checkout_success_shipping_description', true);
+ $data['woopra_checkout_success_total_items_ordered'] = $this->customerSession
+ ->getData('woopra_checkout_success_total_items_ordered', true);
+ $data['woopra_checkout_success_profit'] = $this->customerSession
+ ->getData('woopra_checkout_success_profit', true);
+ $data['woopra_checkout_success_guest_trigger'] = $this->customerSession
+ ->getData('woopra_checkout_success_guest_trigger', true);
+ $data['woopra_checkout_success_guest_name'] = $this->customerSession
+ ->getData('woopra_checkout_success_guest_name', true);
+ $data['woopra_checkout_success_guest_email'] = $this->customerSession
+ ->getData('woopra_checkout_success_guest_email', true);
+ }
+
+ if ($this->dataHelper->getCmsNoRoute() != null) {
+ $data['woopra_cms_noroute_trigger'] = $this->customerSession
+ ->getData('woopra_cms_noroute_trigger', true);
+ $data['woopra_cms_noroute_path'] = $this->customerSession
+ ->getData('woopra_cms_noroute_path', true);
+ $data['woopra_cms_noroute_url'] = $this->_storeManager->getStore()->getCurrentUrl();
+ }
+
+ if ($this->dataHelper->getCouponCodeAdded() != null) {
+ $data['woopra_coupon_code_trigger'] = $this->customerSession
+ ->getData('woopra_coupon_code_trigger', true);
+ $data['woopra_coupon_code_status'] = $this->customerSession
+ ->getData('woopra_coupon_code_status', true);
+ $data['woopra_coupon_code'] = $this->customerSession->getData('woopra_coupon_code', true);
+ $data['woopra_coupon_code_validity'] = $this->customerSession
+ ->getData('woopra_coupon_code_validity', true);
+ $data['woopra_coupon_code_active'] = $this->customerSession
+ ->getData('woopra_coupon_code_active', true);
+ $data['woopra_coupon_code_name'] = $this->customerSession
+ ->getData('woopra_coupon_code_name', true);
+ }
+
+ if ($this->dataHelper->getCustomerLogin() != null) {
+ $data['woopra_login_logout_trigger'] = $this->customerSession
+ ->getData('woopra_login_logout_trigger', true);
+ $data['woopra_login_logout_status'] = $this->customerSession
+ ->getData('woopra_login_logout_status', true);
+ }
+
+ if ($this->dataHelper->getForgotPassword() != null) {
+ $data['woopra_forgot_password_trigger'] = $this->customerSession
+ ->getData('woopra_forgot_password_trigger', true);
+ $data['woopra_forgot_password_email'] = $this->customerSession
+ ->getData('woopra_forgot_password_email', true);
+ }
+
+ if ($this->dataHelper->getChangedPassword() != null) {
+ $data['woopra_password_changed_trigger'] = $this->customerSession
+ ->getData('woopra_password_changed_trigger', true);
+ }
+
+ if ($this->dataHelper->getProductReviewRead() != null && $this->customerSession
+ ->getData('woopra_product_review_trigger') == 1) {
+ $data['woopra_cart_wishlist_status'] = 'product_review_posted';
+ $data['woopra_product_review_trigger'] = $this->customerSession
+ ->getData('woopra_product_review_trigger', true);
+ $data['woopra_product_review_nickname'] = $this->customerSession
+ ->getData('woopra_product_review_nickname', true);
+ $data['woopra_product_review_title'] = $this->customerSession
+ ->getData('woopra_product_review_title', true);
+ $data['woopra_product_review_detail'] = $this->customerSession
+ ->getData('woopra_product_review_detail', true);
+ }
+
+ if ($this->dataHelper->getEstimatePost() != null && $this->customerSession
+ ->getData('woopra_estimate_post_trigger') == 1) {
+ $data['woopra_estimate_post_trigger'] = $this->customerSession
+ ->getData('woopra_estimate_post_trigger', true);
+ $data['woopra_estimate_post_country'] = $this->customerSession
+ ->getData('woopra_estimate_post_country', true);
+ $data['woopra_estimate_post_state'] = $this->customerSession
+ ->getData('woopra_estimate_post_state', true);
+ $data['woopra_estimate_post_zip'] = $this->customerSession
+ ->getData('woopra_estimate_post_zip', true);
+ }
+
+ if ($this->dataHelper->getProductEmailToFriend() != null) {
+ $data['woopra_sendfriend_product_trigger'] = $this->customerSession
+ ->getData('woopra_sendfriend_product_trigger', true);
+ $data['woopra_sendfriend_product_name'] = $this->customerSession
+ ->getData('woopra_sendfriend_product_name', true);
+ $data['woopra_sendfriend_product_sku'] = $this->customerSession
+ ->getData('woopra_sendfriend_product_sku', true);
+ $data['woopra_sendfriend_product_price'] = $this->customerSession
+ ->getData('woopra_sendfriend_product_price', true);
+ }
+ }
+
+ if (isset($data[$key])) {
+ return $data[$key];
+ } else {
+ return null;
+ }
+ }
+
+ public function getCheckoutDetails()
+ {
+ if ($this->dataHelper->getProductPurchased() != null &&
+ $this->getSetting('woopra_checkout_success_trigger') == 1) {
+ $orderIds = $this->checkoutSession->getLastRealOrderId();
+ if (empty($orderIds)) {
+ return;
+ }
+
+ $collection = $this->salesOrderCollection->create();
+ $collection->addFieldToFilter('entity_id', ['in' => $orderIds]);
+ $result = [];
+
+ foreach ($collection as $order) {
+ if ($order->getIsVirtual()) {
+ $address = $order->getBillingAddress();
+ } else {
+ $address = $order->getShippingAddress();
+ }
+
+ foreach ($order->getAllVisibleItems() as $item) {
+ $result[] = sprintf(
+ " woopra.track({
+ name: '".$this->escaper->escapeJsQuote($this->dataHelper->getProductPurchased())."',
+ product_sku: '%s',
+ product_name: '%s',
+ product_price: '%s',
+ product_qty: '%s'
+ });",
+ $this->escapeJsQuote($item->getSku()),
+ $this->escapeJsQuote($item->getName()),
+ round($item->getBasePrice(), 2),
+ round($item->getQtyOrdered(), 2)
+ );
+ }
+ }
+ return implode("\n", $result);
+ }
+ }
+}
diff --git a/Helper/Data.php b/Helper/Data.php
new file mode 100644
index 0000000..893ffe6
--- /dev/null
+++ b/Helper/Data.php
@@ -0,0 +1,327 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Helper;
+
+class Data extends \Magento\Framework\App\Helper\AbstractHelper
+{
+ const ENABLED = 'woopra_analytics/woopra_basic/enabled';
+ const HOSTNAME = 'woopra_analytics/woopra_basic/hostname';
+ const TEST = 'woopra_analytics/woopra_basic/test';
+ const SUBDOMAIN = 'woopra_analytics/woopra_advanced/subdomain';
+ const VISITOR_TIMEOUT = 'woopra_analytics/woopra_advanced/visitor_timeout';
+ const TRACK_URL_PARAMETERS = 'woopra_analytics/woopra_advanced/track_url_parameters';
+ const TRACKING_COOKIE_EXPIRATION = 'woopra_analytics/woopra_advanced/tracking_cookie_expiration';
+ const TRACKING_COOKIE_NAME = 'woopra_analytics/woopra_advanced/tracking_cookie_name';
+ const TRACKING_COOKIE_DOMAIN = 'woopra_analytics/woopra_advanced/tracking_cookie_domain';
+ const TRACKING_COOKIE_PATH = 'woopra_analytics/woopra_advanced/tracking_cookie_path';
+ const PING = 'woopra_analytics/woopra_advanced/ping';
+ const PING_INTERVAL = 'woopra_analytics/woopra_advanced/ping_interval';
+ const DOWNLOAD_TRACKING = 'woopra_analytics/woopra_advanced/download_tracking';
+ const DOWNLOAD_TRACKING_PAUSE = 'woopra_analytics/woopra_advanced/download_tracking_pause';
+ const OUTGOING_TRACKING = 'woopra_analytics/woopra_advanced/outgoing_tracking';
+ const OUTGOING_TRACKING_PAUSE = 'woopra_analytics/woopra_advanced/outgoing_tracking_pause';
+ const OUTGOING_IGNORE_SUBDOMAIN = 'woopra_analytics/woopra_advanced/outgoing_ignore_subdomain';
+ const HIDE_CAMPAIGN = 'woopra_analytics/woopra_advanced/hide_campaign';
+ const NAME = 'woopra_analytics/woopra_outputs/name';
+ const EMAIL = 'woopra_analytics/woopra_outputs/email';
+ const COMPANY = 'woopra_analytics/woopra_outputs/company';
+ const CUSTOMER_LOCATION = 'woopra_analytics/woopra_outputs/customer_location';
+ const CUSTOMER_PHONE = 'woopra_analytics/woopra_outputs/customer_phone';
+ const CUSTOMER_GROUP = 'woopra_analytics/woopra_outputs/customer_group';
+ const CUSTOMER_LIFETIME_SALES = 'woopra_analytics/woopra_outputs/customer_lifetime_sales';
+ const CUSTOMER_NUMBER_ORDERS = 'woopra_analytics/woopra_outputs/customer_number_orders';
+ const CUSTOMER_CREATE_DATE = 'woopra_analytics/woopra_outputs/customer_create_date';
+ const CUSTOMER_CART_ITEMS = 'woopra_analytics/woopra_outputs/customer_cart_items';
+ const CUSTOMER_CART_TOTAL = 'woopra_analytics/woopra_outputs/customer_cart_total';
+ const CUSTOMER_WISHLIST_ITEMS = 'woopra_analytics/woopra_outputs/customer_wishlist_items';
+ const CUSTOMER_WISHLIST_TOTAL = 'woopra_analytics/woopra_outputs/customer_wishlist_total';
+ const CATALOG_SEARCH = 'woopra_analytics/woopra_events/catalog_search';
+ const CHANGED_PASSWORD = 'woopra_analytics/woopra_events/changed_password';
+ const CHECKOUT_BILLING_ADDRESS = 'woopra_analytics/woopra_events/checkout_billing_address';
+ const CHECKOUT_SHIPPING_ADDRESS = 'woopra_analytics/woopra_events/checkout_shipping_address';
+ const CHECKOUT_SHIPPING_METHOD = 'woopra_analytics/woopra_events/checkout_shipping_method';
+ const CHECKOUT_PAYMENT_METHOD = 'woopra_analytics/woopra_events/checkout_payment_method';
+ const CHECKOUT_REVIEW = 'woopra_analytics/woopra_events/checkout_review';
+ const CHECKOUT_SUCCESS = 'woopra_analytics/woopra_events/checkout_success';
+ const CMS_NO_ROUTE = 'woopra_analytics/woopra_events/cms_no_route';
+ const CONTACT_FORM_SENT = 'woopra_analytics/woopra_events/contact_form_sent';
+ const COUPON_ADDED = 'woopra_analytics/woopra_events/coupon_added';
+ const COUPON_REMOVED = 'woopra_analytics/woopra_events/coupon_removed';
+ const CUSTOMER_CREATE_ACCOUNT = 'woopra_analytics/woopra_events/customer_create_account';
+ const CUSTOMER_CREATE_ACCOUNT_SUCCESS = 'woopra_analytics/woopra_events/customer_create_account_success';
+ const CUSTOMER_LOGIN = 'woopra_analytics/woopra_events/customer_login';
+ const CUSTOMER_LOGOUT = 'woopra_analytics/woopra_events/customer_logout';
+ const ESTIMATE_POST = 'woopra_analytics/woopra_events/estimate_post';
+ const FORGOT_PASSWORD = 'woopra_analytics/woopra_events/forgot_password';
+ const NEWSLETTER_SUBSCRIBED = 'woopra_analytics/woopra_events/newsletter_subscribed';
+ const NEWSLETTER_UNSUBSCRIBED = 'woopra_analytics/woopra_events/newsletter_unsubscribed';
+ const PRODUCT_ADDED_TO_CART = 'woopra_analytics/woopra_events/product_added_to_cart';
+ const PRODUCT_REMOVED_FROM_CART = 'woopra_analytics/woopra_events/product_removed_from_cart';
+ const PRODUCT_ADDED_TO_COMPARE = 'woopra_analytics/woopra_events/product_added_to_compare';
+ const PRODUCT_REMOVED_FROM_COMPARE = 'woopra_analytics/woopra_events/product_removed_from_compare';
+ const PRODUCT_ADDED_TO_WISHLIST = 'woopra_analytics/woopra_events/product_added_to_wishlist';
+ const PRODUCT_REMOVED_FROM_WISHLIST = 'woopra_analytics/woopra_events/product_removed_from_wishlist';
+ const PRODUCT_PURCHASED = 'woopra_analytics/woopra_events/product_purchased';
+ const PRODUCT_REVIEW_READ = 'woopra_analytics/woopra_events/product_review_read';
+ const PRODUCT_REVIEW_POSTED = 'woopra_analytics/woopra_events/product_review_posted';
+ const SENDFRIEND_PRODUCT = 'woopra_analytics/woopra_events/sendfriend_product';
+
+ public function __construct(\Magento\Framework\App\Helper\Context $context)
+ {
+ parent::__construct($context);
+ }
+
+ public function getEnabled()
+ {
+ return $this->scopeConfig->getValue(self::ENABLED);
+ }
+ public function getHostname()
+ {
+ return $this->scopeConfig->getValue(self::HOSTNAME);
+ }
+ public function getTest()
+ {
+ return $this->scopeConfig->getValue(self::TEST);
+ }
+ public function getSubdomain()
+ {
+ return $this->scopeConfig->getValue(self::SUBDOMAIN);
+ }
+ public function getVistorTimeout()
+ {
+ return $this->scopeConfig->getValue(self::VISITOR_TIMEOUT);
+ }
+ public function getTrackUrlParameters()
+ {
+ return $this->scopeConfig->getValue(self::TRACK_URL_PARAMETERS);
+ }
+ public function getTrackingCookieExpiration()
+ {
+ return $this->scopeConfig->getValue(self::TRACKING_COOKIE_EXPIRATION);
+ }
+ public function getTrackingCookieName()
+ {
+ return $this->scopeConfig->getValue(self::TRACKING_COOKIE_NAME);
+ }
+ public function getTrackingCookieDomain()
+ {
+ return $this->scopeConfig->getValue(self::TRACKING_COOKIE_DOMAIN);
+ }
+ public function getTrackingCookiePath()
+ {
+ return $this->scopeConfig->getValue(self::TRACKING_COOKIE_PATH);
+ }
+ public function getPing()
+ {
+ return $this->scopeConfig->getValue(self::PING);
+ }
+ public function getPingInterval()
+ {
+ return $this->scopeConfig->getValue(self::PING_INTERVAL);
+ }
+ public function getDownloadTracking()
+ {
+ return $this->scopeConfig->getValue(self::DOWNLOAD_TRACKING);
+ }
+ public function getDownloadTrackingPause()
+ {
+ return $this->scopeConfig->getValue(self::DOWNLOAD_TRACKING_PAUSE);
+ }
+ public function getOutgoingTracking()
+ {
+ return $this->scopeConfig->getValue(self::OUTGOING_TRACKING);
+ }
+ public function getOutgoingTrackingPause()
+ {
+ return $this->scopeConfig->getValue(self::OUTGOING_TRACKING_PAUSE);
+ }
+ public function getOutgoingIgnoreSubdomain()
+ {
+ return $this->scopeConfig->getValue(self::OUTGOING_IGNORE_SUBDOMAIN);
+ }
+ public function getHideCampaign()
+ {
+ return $this->scopeConfig->getValue(self::HIDE_CAMPAIGN);
+ }
+ public function getCustomerName()
+ {
+ return $this->scopeConfig->getValue(self::NAME);
+ }
+ public function getCustomerEmail()
+ {
+ return $this->scopeConfig->getValue(self::EMAIL);
+ }
+ public function getCustomerCompany()
+ {
+ return $this->scopeConfig->getValue(self::COMPANY);
+ }
+ public function getCustomerLocation()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_LOCATION);
+ }
+ public function getCustomerPhone()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_PHONE);
+ }
+ public function getCustomerGroup()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_GROUP);
+ }
+ public function getCustomerLifetimeSales()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_LIFETIME_SALES);
+ }
+ public function getCustomerNumberOrders()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_NUMBER_ORDERS);
+ }
+ public function getCustomerCreateDate()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_CREATE_DATE);
+ }
+ public function getCustomerCartItems()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_CART_ITEMS);
+ }
+ public function getCustomerCartTotal()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_CART_TOTAL);
+ }
+ public function getCustomerWishlistItems()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_WISHLIST_ITEMS);
+ }
+ public function getCustomerWishlistTotal()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_WISHLIST_TOTAL);
+ }
+ public function getCatalogSearch()
+ {
+ return $this->scopeConfig->getValue(self::CATALOG_SEARCH);
+ }
+ public function getChangedPassword()
+ {
+ return $this->scopeConfig->getValue(self::CHANGED_PASSWORD);
+ }
+ public function getCheckoutBillingAddress()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_BILLING_ADDRESS);
+ }
+ public function getCheckoutShippingAddress()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_SHIPPING_ADDRESS);
+ }
+ public function getCheckoutShippingMethod()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_SHIPPING_METHOD);
+ }
+ public function getCheckoutPaymentMethod()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_PAYMENT_METHOD);
+ }
+ public function getCheckoutReview()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_REVIEW);
+ }
+ public function getCheckoutSuccess()
+ {
+ return $this->scopeConfig->getValue(self::CHECKOUT_SUCCESS);
+ }
+ public function getCmsNoRoute()
+ {
+ return $this->scopeConfig->getValue(self::CMS_NO_ROUTE);
+ }
+ public function getContactFormSent()
+ {
+ return $this->scopeConfig->getValue(self::CONTACT_FORM_SENT);
+ }
+ public function getCouponCodeAdded()
+ {
+ return $this->scopeConfig->getValue(self::COUPON_ADDED);
+ }
+ public function getCouponCodeRemoved()
+ {
+ return $this->scopeConfig->getValue(self::COUPON_REMOVED);
+ }
+ public function getCustomerCreateAccount()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_CREATE_ACCOUNT);
+ }
+ public function getCustomerCreateAccountSuccess()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_CREATE_ACCOUNT_SUCCESS);
+ }
+ public function getCustomerLogin()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_LOGIN);
+ }
+ public function getCustomerLogout()
+ {
+ return $this->scopeConfig->getValue(self::CUSTOMER_LOGOUT);
+ }
+ public function getEstimatePost()
+ {
+ return $this->scopeConfig->getValue(self::ESTIMATE_POST);
+ }
+ public function getForgotPassword()
+ {
+ return $this->scopeConfig->getValue(self::FORGOT_PASSWORD);
+ }
+ public function getNewsletterSubscribed()
+ {
+ return $this->scopeConfig->getValue(self::NEWSLETTER_SUBSCRIBED);
+ }
+ public function getNewsletterUnsubscribed()
+ {
+ return $this->scopeConfig->getValue(self::NEWSLETTER_UNSUBSCRIBED);
+ }
+ public function getProductAddedToCart()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_ADDED_TO_CART);
+ }
+ public function getProductRemovedFromCart()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_REMOVED_FROM_CART);
+ }
+ public function getProductAddedToCompare()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_ADDED_TO_COMPARE);
+ }
+ public function getProductRemovedFromCompare()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_REMOVED_FROM_COMPARE);
+ }
+ public function getProductAddedToWishlist()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_ADDED_TO_WISHLIST);
+ }
+ public function getProductRemovedFromWishlist()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_REMOVED_FROM_WISHLIST);
+ }
+ public function getProductPurchased()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_PURCHASED);
+ }
+ public function getProductReviewRead()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_REVIEW_READ);
+ }
+ public function getProductReviewPosted()
+ {
+ return $this->scopeConfig->getValue(self::PRODUCT_REVIEW_POSTED);
+ }
+ public function getProductEmailToFriend()
+ {
+ return $this->scopeConfig->getValue(self::SENDFRIEND_PRODUCT);
+ }
+}
diff --git a/Observer/CartAddObserver.php b/Observer/CartAddObserver.php
new file mode 100644
index 0000000..e34049e
--- /dev/null
+++ b/Observer/CartAddObserver.php
@@ -0,0 +1,52 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class CartAddObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getProductAddedToCart() != null) {
+ $event = $observer->getEvent();
+ if ($event) {
+ $product = $event->getProduct();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductAddedToCart()
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_name', $product['name']);
+ $this->customerSession->setData('woopra_cart_wishlist_sku', $product['sku']);
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ }
+ }
+ }
+}
diff --git a/Observer/CartRemoveObserver.php b/Observer/CartRemoveObserver.php
new file mode 100644
index 0000000..61ac39c
--- /dev/null
+++ b/Observer/CartRemoveObserver.php
@@ -0,0 +1,52 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class CartRemoveObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getProductRemovedFromCart() != null) {
+ $event = $observer->getEvent();
+ if ($event) {
+ $product = $event->getQuoteItem()->getProduct();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductRemovedFromCart()
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_name', $product['name']);
+ $this->customerSession->setData('woopra_cart_wishlist_sku', $product['sku']);
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ }
+ }
+ }
+}
diff --git a/Observer/CustomerLoginObserver.php b/Observer/CustomerLoginObserver.php
new file mode 100644
index 0000000..6561e87
--- /dev/null
+++ b/Observer/CustomerLoginObserver.php
@@ -0,0 +1,45 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class CustomerLoginObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ $event = $observer->getEvent();
+ if ($event) {
+ if ($this->dataHelper->getCustomerLogin() != null) {
+ $this->customerSession->setData('woopra_login_logout_trigger', 1);
+ $this->customerSession->setData('woopra_login_logout_status', $this->dataHelper->getCustomerLogin());
+ }
+ }
+ }
+}
diff --git a/Observer/NewsletterManageObserver.php b/Observer/NewsletterManageObserver.php
new file mode 100644
index 0000000..461541f
--- /dev/null
+++ b/Observer/NewsletterManageObserver.php
@@ -0,0 +1,64 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class NewsletterManageObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getNewsletterSubscribed() != null) {
+ $event = $observer->getEvent();
+ $model = $event->getSubscriber();
+ $subscriberEmail = $model->getData('subscriber_email');
+ if ($model->getIsStatusChanged() == 1 && $model->getData('subscriber_status') == 1) {
+ $this->customerSession->setData('woopra_subscriber_changed', 1);
+ $this->customerSession->setData(
+ 'woopra_subscriber_status',
+ $this->dataHelper->getNewsletterSubscribed()
+ );
+ $this->customerSession->setData(
+ 'woopra_subscriber_email',
+ $this->escapeHtml($subscriberEmail)
+ );
+ } elseif ($model->getIsStatusChanged() == 1 && $model->getData('subscriber_status') == 3) {
+ $this->customerSession->setData('woopra_subscriber_changed', 1);
+ $this->customerSession->setData(
+ 'woopra_subscriber_status',
+ $this->dataHelper->getNewsletterUnsubscribed()
+ );
+ $this->customerSession->setData(
+ 'woopra_subscriber_email',
+ $this->escapeHtml($subscriberEmail)
+ );
+ }
+ }
+ }
+}
diff --git a/Observer/Observer.php b/Observer/Observer.php
new file mode 100644
index 0000000..b268a9a
--- /dev/null
+++ b/Observer/Observer.php
@@ -0,0 +1,356 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Checkout\Model\Session\Proxy as CheckoutSession;
+use Magento\Customer\Model\Session\Proxy as CustomerSession;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Escaper;
+use Magento\Framework\Event\ObserverInterface;
+use Magento\Sales\Model\Order;
+use Woopra\Analytics\Helper\Data;
+
+class Observer implements ObserverInterface
+{
+ private $checkoutSession;
+ private $customerSession;
+ private $dataHelper;
+ private $escaper;
+ private $order;
+ private $productRepository;
+ private $request;
+
+ public function __construct(
+ CheckoutSession $checkoutSession,
+ CustomerSession $customerSession,
+ Data $dataHelper,
+ Escaper $escaper,
+ Order $order,
+ ProductRepository $productRepository,
+ Http $request
+ ) {
+ $this->checkoutSession = $checkoutSession;
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->escaper = $escaper;
+ $this->order = $order;
+ $this->productRepository = $productRepository;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->request->getFullActionName() == 'customer_account_logoutSuccess' &&
+ $this->dataHelper->getCustomerLogout() != null) {
+ $this->customerSession->setData('woopra_login_logout_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_login_logout_status',
+ $this->dataHelper->getCustomerLogout()
+ );
+ }
+
+ if ($this->request->getFullActionName() == 'contacts_index_post' &&
+ $this->dataHelper->getContactFormSent() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $this->customerSession->setData('woopra_contacts_index_post', 1);
+ $this->customerSession->setData(
+ 'woopra_contacts_name',
+ $this->escaper->escapeHtml($request['name'])
+ );
+ $this->customerSession->setData(
+ 'woopra_contacts_email',
+ $this->escaper->escapeHtml($request['email'])
+ );
+ $this->customerSession->setData(
+ 'woopra_contacts_telephone',
+ $this->escaper->escapeHtml($request['telephone'])
+ );
+ $this->customerSession->setData(
+ 'woopra_contacts_comment',
+ $this->escaper->escapeHtml($request['comment'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() == 'wishlist_index_remove' &&
+ $this->dataHelper->getProductRemovedFromWishlist() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductRemovedFromWishlist()
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() == 'checkout_onepage_index' &&
+ $this->dataHelper->getCheckoutBillingAddress() != null) {
+ $this->customerSession->setData('woopra_checkout_trigger', 1);
+ }
+
+ if ($this->request->getFullActionName() == 'checkout_onepage_savePayment' &&
+ $this->dataHelper->getCheckoutPaymentMethod() != null) {
+ $request = $this->request->getParams();
+ $this->customerSession->setData('woopra_checkout_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_checkout_payment_method',
+ $request['payment']['method']
+ );
+ if ($request['payment']['method'] == 'ccsave') {
+ $this->customerSession->setData(
+ 'woopra_checkout_payment_cc_type',
+ $request['payment']['cc_type']
+ );
+ }
+ }
+
+ if (($this->request->getFullActionName() == 'checkout_onepage_success' ||
+ $this->request->getFullActionName() == 'checkout_multishipping_success')
+ && $this->dataHelper->getCheckoutSuccess() != null) {
+ $lastOrderId = $this->checkoutSession->getLastRealOrderId();
+ if ($lastOrderId) {
+ $order = $this->order->loadByIncrementId($lastOrderId);
+ $cost = 0;
+ $this->customerSession->setData('woopra_checkout_success_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_checkout_success_coupon_code',
+ $order->getCouponCode()
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_discount_amount',
+ round($order->getDiscountAmount(), 2)
+ );
+ $this->customerSession->setData('woopra_checkout_success_order_id', $lastOrderId);
+ $this->customerSession->setData(
+ 'woopra_checkout_success_order_subtotal',
+ round($order->getSubtotal(), 2)
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_order_total',
+ round($order->getGrandTotal(), 2)
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_order_weight',
+ round($order->getWeight(), 2)
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_shipping_amount',
+ round($order->getShippingAmount(), 2)
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_shipping_description',
+ $order->getShippingDescription()
+ );
+ $this->customerSession->setData(
+ 'woopra_checkout_success_total_items_ordered',
+ round($order->getTotalQtyOrdered(), 0)
+ );
+ $items = $order->getAllVisibleItems();
+ foreach ($items as $item) {
+ $cost = $cost + round($this->productRepository->getById($item->getProductId())->getData('cost'), 2);
+ }
+ $profit = $order->getSubtotal() - $cost;
+ if ($cost != 0) {
+ $this->customerSession->setData('woopra_checkout_success_profit', round($profit, 2));
+ }
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'catalogsearch_result_index' &&
+ $this->dataHelper->getCatalogSearch() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $this->customerSession->setData('woopra_search_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_search_keywords',
+ $this->escaper->escapeHtml($request['q'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'catalogsearch_advanced_result' &&
+ $this->dataHelper->getCatalogSearch() != null) {
+ $request = $this->request->getParams();
+ $subtotal = '';
+ $searchKeywords = '';
+ if ($request) {
+ foreach ($request as $key => $answer) {
+ if (is_array($answer) == true) {
+ foreach ($answer as $subkey => $subanswer) {
+ $subtotal = $subtotal." ".$subkey.":".$subanswer;
+ $answer = $subtotal;
+ }
+ $subtotal = '';
+ }
+ $searchKeywords = $searchKeywords." | ".$key.": ".$answer;
+ }
+ $this->customerSession->setData('woopra_search_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_search_keywords',
+ $this->escaper->escapeHtml($searchKeywords)
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'review_product_list' &&
+ $this->dataHelper->getProductReviewRead() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $product = $this->productRepository->getById($request['id'])->getData();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductReviewRead()
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_name', $product['name']);
+ $this->customerSession->setData('woopra_cart_wishlist_sku', $product['sku']);
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'review_product_post' &&
+ $this->dataHelper->getProductReviewPosted() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $product = $this->productRepository->getById($request['id'])->getData();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductReviewPosted()
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_name', $product['name']);
+ $this->customerSession->setData('woopra_cart_wishlist_sku', $product['sku']);
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ $this->customerSession->setData('woopra_product_review_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_product_review_nickname',
+ $this->escaper->escapeHtml($request['nickname'])
+ );
+ $this->customerSession->setData(
+ 'woopra_product_review_title',
+ $this->escaper->escapeHtml($request['title'])
+ );
+ $this->customerSession->setData(
+ 'woopra_product_review_detail',
+ $this->escaper->escapeHtml($request['detail'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'customer_account_forgotpasswordpost' &&
+ $this->dataHelper->getForgotPassword() != null) {
+ $request = $this->request->getParams();
+ $this->customerSession->setData('woopra_forgot_password_trigger', 1);
+ if ($request) {
+ $this->customerSession->setData(
+ 'woopra_forgot_password_email',
+ $this->escaper->escapeHtml($request['email'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'customer_account_editPost' &&
+ $this->dataHelper->getChangedPassword() != null) {
+ $request = $this->request->getParams();
+ if ($request['change_password'] == 1 && $request['current_password'] != $request['password']) {
+ $this->customerSession->setData('woopra_password_changed_trigger', 1);
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'checkout_cart_couponPost' &&
+ $this->dataHelper->getCouponCodeAdded() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $this->customerSession->setData('woopra_coupon_code_trigger', 1);
+ if ($request['remove'] == 1) {
+ $this->customerSession->setData(
+ 'woopra_coupon_code_status',
+ $this->dataHelper->getCouponCodeRemoved()
+ );
+ } else {
+ $this->customerSession->setData(
+ 'woopra_coupon_code_status',
+ $this->dataHelper->getCouponCodeAdded()
+ );
+ }
+ $this->customerSession->setData(
+ 'woopra_coupon_code',
+ $this->escaper->escapeHtml($request['coupon_code'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'customer_account_create' &&
+ $this->dataHelper->getCustomerCreateAccount() != null) {
+ $this->customerSession->setData('woopra_create_account_trigger', 1);
+ }
+
+ if ($this->request->getFullActionName() === 'customer_account_createpost' &&
+ $this->dataHelper->getCustomerCreateAccount() != null) {
+ $request = $this->request->getParams();
+ $this->customerSession->setData('woopra_create_account_success_trigger', 1);
+ if (isset($request['is_subscribed'])) {
+ if ($request['is_subscribed'] == 1) {
+ $this->customerSession->setData('woopra_subscriber_changed', 1);
+ $this->customerSession->setData(
+ 'woopra_subscriber_status',
+ $this->dataHelper->getNewsletterSubscribed()
+ );
+ $this->customerSession->setData(
+ 'woopra_subscriber_email',
+ $this->escaper->escapeHtml($request['email'])
+ );
+ }
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'checkout_cart_estimatePost' &&
+ $this->dataHelper->getEstimatePost() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $this->customerSession->setData('woopra_estimate_post_trigger', 1);
+ $this->customerSession->setData('woopra_estimate_post_country', $request['country_id']);
+ $this->customerSession->setData(
+ 'woopra_estimate_post_zip',
+ $this->escaper->escapeHtml($request['estimate_postcode'])
+ );
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'cms_noroute_index' &&
+ $this->dataHelper->getCmsNoRoute() != null) {
+ $request = $this->request->getOriginalPathInfo();
+ $this->customerSession->setData('woopra_cms_noroute_trigger', 1);
+ if ($request) {
+ $this->customerSession->setData('woopra_cms_noroute_path', $request);
+ }
+ }
+
+ if ($this->request->getFullActionName() === 'sendfriend_product_sendmail' &&
+ $this->dataHelper->getProductEmailToFriend() != null) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $product = $this->productRepository->getById($request['id'])->getData();
+ $this->customerSession->setData('woopra_sendfriend_product_name', $product['name']);
+ $this->customerSession->setData('woopra_sendfriend_product_sku', $product['sku']);
+ $this->customerSession->setData(
+ 'woopra_sendfriend_product_price',
+ round($product['price'], 2)
+ );
+ $this->customerSession->setData('woopra_sendfriend_product_trigger', 1);
+ }
+ }
+ }
+}
diff --git a/Observer/ProductCompareAddObserver.php b/Observer/ProductCompareAddObserver.php
new file mode 100644
index 0000000..74aba67
--- /dev/null
+++ b/Observer/ProductCompareAddObserver.php
@@ -0,0 +1,58 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class ProductCompareAddObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getProductAddedToCompare() != null) {
+ $event = $observer->getEvent();
+ if ($event) {
+ $product = $event->getProduct();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductAddedToCompare()
+ );
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_name',
+ $product['name']
+ );
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_sku',
+ $product['sku']
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ }
+ }
+ }
+}
diff --git a/Observer/ProductCompareRemoveObserver.php b/Observer/ProductCompareRemoveObserver.php
new file mode 100644
index 0000000..c127de0
--- /dev/null
+++ b/Observer/ProductCompareRemoveObserver.php
@@ -0,0 +1,60 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class ProductCompareRemoveObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $productRepository;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ ProductRepository $productRepository,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->productRepository = $productRepository;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getProductRemovedFromCompare() != null) {
+ $event = $observer->getEvent();
+ if ($event) {
+ $productId = $event->getProduct()->getProductId();
+ $product = $this->productRepository->getById($productId)->getData();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductRemovedFromCompare()
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_name', $product['name']);
+ $this->customerSession->setData('woopra_cart_wishlist_sku', $product['sku']);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_price',
+ round($product['price'], 2)
+ );
+ }
+ }
+ }
+}
diff --git a/Observer/WishlistAddObserver.php b/Observer/WishlistAddObserver.php
new file mode 100644
index 0000000..4d18411
--- /dev/null
+++ b/Observer/WishlistAddObserver.php
@@ -0,0 +1,65 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+namespace Woopra\Analytics\Observer;
+
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Customer\Model\Session;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\Event\ObserverInterface;
+use Woopra\Analytics\Helper\Data;
+
+class WishlistAddObserver implements ObserverInterface
+{
+ private $customerSession;
+ private $dataHelper;
+ private $productRepository;
+ private $request;
+
+ public function __construct(
+ Data $dataHelper,
+ Http $request,
+ ProductRepository $productRepository,
+ Session $customerSession
+ ) {
+ $this->customerSession = $customerSession;
+ $this->dataHelper = $dataHelper;
+ $this->productRepository = $productRepository;
+ $this->request = $request;
+ }
+
+ public function execute(\Magento\Framework\Event\Observer $observer)
+ {
+ if ($this->dataHelper->getProductAddedToWishlist() != null) {
+ $event = $observer->getEvent();
+ if ($event) {
+ $request = $this->request->getParams();
+ if ($request) {
+ $product = $this->productRepository->getById($request['product'])->getData();
+ $this->customerSession->setData('woopra_cart_wishlist_trigger', 1);
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_status',
+ $this->dataHelper->getProductAddedToWishlist()
+ );
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_name',
+ $product['name']
+ );
+ $this->customerSession->setData(
+ 'woopra_cart_wishlist_sku',
+ $product['sku']
+ );
+ $this->customerSession->setData('woopra_cart_wishlist_price', round($product['price'], 2));
+ }
+ }
+ }
+ }
+}
diff --git a/README.md b/README.md
index 1b3e9db..250a5c7 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,4 @@
-# magento2-woopra
\ No newline at end of file
+# magento2-woopra
+=============
+
+Magento2 Integration with Woopra Real-Time Analytics
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..7dbaea9
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,18 @@
+{
+ "name": "woopra/analytics-m2",
+ "license": "OSL-3.0",
+ "description": "woopra analytics",
+ "type": "magento2-module",
+ "version": "1.0.0",
+ "require": {
+ "php": "~5.5.0|~5.6.0|~7.0.0"
+ },
+ "autoload": {
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Woopra\\Analytics\\": ""
+ }
+ }
+}
diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml
new file mode 100644
index 0000000..98ba86a
--- /dev/null
+++ b/etc/adminhtml/routes.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
new file mode 100644
index 0000000..f2ca8f7
--- /dev/null
+++ b/etc/adminhtml/system.xml
@@ -0,0 +1,408 @@
+
+
+
+
+
+
+
+
+
+ woopra
+ Woopra_Analytics::woopra_analytics
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Enable or disable the Woopra module
+
+
+
+
+
+ Enter hostname to track (ie: example.com).
+
+
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
+
+
+
+
+
+
+ Enter subdomain to track (ie: subdomain).
+
+
+
+
+
+ The idle time in minutes after which visitors are considered no longer on your website (Default: 30)
+
+
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
+ Include queries in the url (Default No)
+
+
+
+
+
+ The tracking cookie expiration in days (Default: 730)
+
+
+
+
+
+ Change the name of the cookie stored by Woopra (Default: wooTracker)
+
+
+
+
+
+ Change the tracking cookie domain
+
+
+
+
+
+ Change the tracking cookie path (Default: /)
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Enable/Disable the periodic pings (Default: Enable)
+
+
+
+
+
+ Change ping interval (Default: 12000 milliseconds)
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Enable/Disable download tracking (Default: Disable)
+
+
+
+
+
+ Change download pause to guarantee the tracking request is sent (Default: 200 milliseconds)
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Enable/Disable outgoing links tracking (Default: Disable)
+
+
+
+
+
+ Change outgoing link pause to guarantee the tracking request is sent (Default: 400 milliseconds)
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Do not include links to subdomains as outgoing links (Default: Enable)
+
+
+
+
+ Magento\Config\Model\Config\Source\Enabledisable
+
+ Enabling this option will remove campaign properties from the URL when they’re captured (Default: Disabled)
+
+
+
+
+
+ You can disable outputs here that you do not want to use. On some servers a performance gain may be noticed by disabling unused calls.
+
+
+
+ Customer name output name (empty to disable). Note: This is a reserved property and should not be changed!
+
+
+
+
+
+ Customer email output name (empty to disable). Note: This is a reserved property and should not be changed!
+
+
+
+
+
+ Customer company output name (empty to disable). Note: This is a reserved property and should not be changed!
+
+
+
+
+
+ Customer location output name (empty to disable).
+
+
+
+
+
+ Customer phone output name (empty to disable).
+
+
+
+
+
+ Customer group output name (empty to disable).
+
+
+
+
+
+ Customer lifetime sales output name (empty to disable).
+
+
+
+
+
+ Customer number of orders output name (empty to disable).
+
+
+
+
+
+ Customer account creation date output name (empty to disable).
+
+
+
+
+
+ Customer total items in cart output name (empty to disable).
+
+
+
+
+
+ Customer cart total output name (empty to disable).
+
+
+
+
+
+ Customer total items in wishlist output name (empty to disable).
+
+
+
+
+
+ Customer wishlist total output name (empty to disable).
+
+
+
+
+
+ You can disable event tracking here that you do not want to use. On some servers a performance gain may be noticed by disabling unused calls.
+
+
+
+ Catalog search event tracking name (empty to disable).
+
+
+
+
+
+ Changed password event tracking name (empty to disable).
+
+
+
+
+
+ Checkout step billing address event tracking name (empty to disable).
+
+
+
+
+
+ Checkout step shipping address event tracking name (empty to disable).
+
+
+
+
+
+ Checkout step billing address event tracking name (empty to disable).
+
+
+
+
+
+ Checkout step payment method event tracking name (empty to disable).
+
+
+
+
+
+ Checkout step review event tracking name (empty to disable).
+
+
+
+
+
+ Checkout success event tracking name (empty to disable).
+
+
+
+
+
+ CMS no route (404) event tracking name (empty to disable).
+
+
+
+
+
+ Contact form sent event tracking name (empty to disable).
+
+
+
+
+
+ Coupon code added event tracking name (empty to disable).
+
+
+
+
+
+ Coupon code removed event tracking name (empty to disable).
+
+
+
+
+
+ Customer create account event tracking name (empty to disable).
+
+
+
+
+
+ Customer create account success event tracking name (empty to disable).
+
+
+
+
+
+ Customer login event tracking name (empty to disable).
+
+
+
+
+
+ Customer logout event tracking name (empty to disable).
+
+
+
+
+
+ Estimate post event tracking name (empty to disable).
+
+
+
+
+
+ Forgot password event tracking name (empty to disable).
+
+
+
+
+
+ Newsletter subscribed event tracking name (empty to disable).
+
+
+
+
+
+ Newsletter unsubscribed event tracking name (empty to disable).
+
+
+
+
+
+ Product added to cart event tracking name (empty to disable).
+
+
+
+
+
+ Product removed from cart event tracking name (empty to disable).
+
+
+
+
+
+ Product added to compare event tracking name (empty to disable).
+
+
+
+
+
+ Product removed from compare event tracking name (empty to disable).
+
+
+
+
+
+ Product added to wishlist event tracking name (empty to disable).
+
+
+
+
+
+ Product removed from wishlist event tracking name (empty to disable).
+
+
+
+
+
+ Product purchased name (empty to disable).
+
+
+
+
+
+ Product review read event tracking name (empty to disable).
+
+
+
+
+
+ Product review posted event tracking name (empty to disable).
+
+
+
+
+
+ Product email to a friend event tracking name (empty to disable).
+
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/config.xml b/etc/config.xml
new file mode 100644
index 0000000..59452e2
--- /dev/null
+++ b/etc/config.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+ 1
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 1
+
+ 0
+
+ 0
+
+ 1
+
+
+
+ name
+ email
+ company
+ magento customer_location
+ magento customer_phone
+ magento customer_group
+ magento customer_lifetime_sales
+ magento customer_number_orders
+ magento customer_create_date
+ magento customer_cart_items
+ magento customer_cart_total
+ magento customer_wishlist_items
+ magento customer_wishlist_total
+
+
+ magento catalog_search
+ magento changed_password
+ magento checkout_billing_address
+ magento checkout_shipping_address
+ magento checkout_shipping_method
+ magento checkout_payment_method
+ magento checkout_review
+ magento checkout_success
+ magento cms_no_route
+ magento contact_form_sent
+ magento coupon_added
+ magento coupon_removed
+ magento customer_create_account
+ magento customer_create_account_success
+ magento customer_login
+ magento customer_logout
+ magento estimate_post
+ magento forgot_password
+ magento newsletter_subscribed
+ magento newsletter_unsubscribed
+ magento product_added_to_cart
+ magento product_removed_from_cart
+ magento product_added_to_compare
+ magento product_removed_from_compare
+ magento product_added_to_wishlist
+ magento product_removed_from_wishlist
+ magento product_purchased
+ magento product_review_read
+ magento product_review_posted
+ magento sendfriend_product
+
+
+
+
\ No newline at end of file
diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml
new file mode 100644
index 0000000..c950b8f
--- /dev/null
+++ b/etc/frontend/events.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/etc/module.xml b/etc/module.xml
new file mode 100644
index 0000000..5726e7b
--- /dev/null
+++ b/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/registration.php b/registration.php
new file mode 100644
index 0000000..6947e28
--- /dev/null
+++ b/registration.php
@@ -0,0 +1,16 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+\Magento\Framework\Component\ComponentRegistrar::register(
+ \Magento\Framework\Component\ComponentRegistrar::MODULE,
+ 'Woopra_Analytics',
+ __DIR__
+);
diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml
new file mode 100644
index 0000000..b13fec8
--- /dev/null
+++ b/view/frontend/layout/default.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/view/frontend/requirejs-config.js b/view/frontend/requirejs-config.js
new file mode 100644
index 0000000..f23fdbc
--- /dev/null
+++ b/view/frontend/requirejs-config.js
@@ -0,0 +1,22 @@
+
+var config = {
+ config: {
+ mixins: {
+ 'Magento_Checkout/js/action/place-order': {
+ 'Woopra_Analytics/js/action/place-order': true
+ },
+ 'Magento_Checkout/js/view/shipping': {
+ 'Woopra_Analytics/js/view/shipping': true
+ },
+ 'Magento_Customer/js/action/check-email-availability': {
+ 'Woopra_Analytics/js/action/check-email-availability': true
+ },
+ 'Magento_Checkout/js/model/shipping-rate-processor/new-address': {
+ 'Woopra_Analytics/js/model/shipping-rate-processor/new-address': true
+ },
+ 'Magento_Checkout/js/model/shipping-rate-processor/customer-address' : {
+ 'Woopra_Analytics/js/model/shipping-rate-processor/customer-address': true
+ }
+ }
+ }
+};
diff --git a/view/frontend/templates/script.phtml b/view/frontend/templates/script.phtml
new file mode 100644
index 0000000..a0e1ddd
--- /dev/null
+++ b/view/frontend/templates/script.phtml
@@ -0,0 +1,365 @@
+
+ * @copyright 2017 Copyright (c) Woopra (http://www.woopra.com/)
+ * @license Open Software License (OSL 3.0)
+ */
+
+?>
+getSetting('enabled')) { ?>
+
+
+getSetting('test')) { ?>
+
+
+
\ No newline at end of file
diff --git a/view/frontend/web/js/action/check-email-availability.js b/view/frontend/web/js/action/check-email-availability.js
new file mode 100644
index 0000000..61b211b
--- /dev/null
+++ b/view/frontend/web/js/action/check-email-availability.js
@@ -0,0 +1,13 @@
+
+define(['mage/utils/wrapper'], function (wrapper) {
+ 'use strict';
+
+ return function (checkEmailAction) {
+ return wrapper.wrap(checkEmailAction, function (originalAction, deferred, email) {
+ woopra.track({
+ name: 'magento check_email_availability'
+ });
+ return originalAction(deferred, email);
+ });
+ };
+});
diff --git a/view/frontend/web/js/action/place-order.js b/view/frontend/web/js/action/place-order.js
new file mode 100644
index 0000000..1b02704
--- /dev/null
+++ b/view/frontend/web/js/action/place-order.js
@@ -0,0 +1,13 @@
+
+define(['mage/utils/wrapper'], function (wrapper) {
+ 'use strict';
+
+ return function (placeOrderAction) {
+ return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, redirectOnSuccess) {
+ woopra.track({
+ name: 'magento checkout_order_placed'
+ });
+ return originalAction(paymentData, redirectOnSuccess);
+ });
+ };
+});
diff --git a/view/frontend/web/js/model/shipping-rate-processor/customer-address.js b/view/frontend/web/js/model/shipping-rate-processor/customer-address.js
new file mode 100644
index 0000000..5136379
--- /dev/null
+++ b/view/frontend/web/js/model/shipping-rate-processor/customer-address.js
@@ -0,0 +1,15 @@
+
+define(['mage/utils/wrapper'], function (wrapper) {
+ 'use strict';
+
+ return function (target) {
+ target.getRates = wrapper.wrap(target.getRates, function (originalAction, address) {
+ woopra.track({
+ name: 'magento checkout_shipping_address'
+ });
+ return originalAction(address);
+ });
+ return target;
+ };
+});
+
diff --git a/view/frontend/web/js/model/shipping-rate-processor/new-address.js b/view/frontend/web/js/model/shipping-rate-processor/new-address.js
new file mode 100644
index 0000000..5136379
--- /dev/null
+++ b/view/frontend/web/js/model/shipping-rate-processor/new-address.js
@@ -0,0 +1,15 @@
+
+define(['mage/utils/wrapper'], function (wrapper) {
+ 'use strict';
+
+ return function (target) {
+ target.getRates = wrapper.wrap(target.getRates, function (originalAction, address) {
+ woopra.track({
+ name: 'magento checkout_shipping_address'
+ });
+ return originalAction(address);
+ });
+ return target;
+ };
+});
+
diff --git a/view/frontend/web/js/view/shipping.js b/view/frontend/web/js/view/shipping.js
new file mode 100644
index 0000000..90953f3
--- /dev/null
+++ b/view/frontend/web/js/view/shipping.js
@@ -0,0 +1,15 @@
+
+define(function () {
+ 'use strict';
+
+ return function (target) {
+ return target.extend({
+ setShippingInformation: function () {
+ woopra.track({
+ name: 'magento checkout_shipping_method'
+ });
+ this._super();
+ }
+ });
+ }
+});