Search Results

Connecting to two different ActiveCampaign accounts

This is an case study in how we’ve use the classes and methods discussed earlier in this section to help a customer solve a very unique problem. This customer is using ActiveCampaign as his CRM, and has a very large contact list (over 25,000 contacts). This customer had two types of WordPress users he needed to track in ActiveCampaign: Customers, and Affiliates. For his small group of affiliates, he needed the pipeline automation and sales attribution features that come with ActiveCampaign’s Professional plan. But a Professional plan for 25,000 contacts would cost $599 a month. The approach It didn’t make sense to be paying for the Professional package when those features were only needed for a small subset of his contacts. So we proposed to set up two ActiveCampaign accounts— one on the Lite plan for his primary list, and a second Professional account for his affiliates and partners. The solution Out of the box, WP Fusion can only connect to one CRM at a time. But the flexibility of WP Fusion’s framework makes it easy to solve even very complex requirements like this. You can see the finished plugin file on GitHub here, or continue reading below for a more detailed explanation. Setting things up As we discussed in the introduction to WP Fusion’s CRM API, all communication with your CRM is done via interfacing with the wp_fusion()->crm object. In this case, it was configured to connect to the main ActiveCampaign account, the one with all of the customers. Let’s call that Account A — Customers What we want to do is create a new wp_fusion()->crm object, this time connected to the AC account for affiliates and partners. We’ll call that Account B — Affiliates When an affiliate registers or updates their account, we’ll temporarily swap the CRM objects, so the contact data is sent to the right place. define( ‘ACCOUNT_TWO_URL’, ‘https://account2.api-us1.com’ ); define( ‘ACCOUNT_TWO_KEY’, ‘APIKEY’ ); define( ‘WPF_DISABLE_QUEUE’, true ); global $wpf_ac_app_swap; global $wpf_ac_switched; $wpf_ac_app_swap = false; $wpf_ac_switched = false; In the first lines of the plugin, we’re defining two constants, ACCOUNT_TWO_URL, and ACCOUNT_TWO_KEY. This will be used to initialize the connection to the second account. We also need to disable WP Fusion’s API queue in this case, because it doesn’t play nicely with swapping the active CRM multiple times on a page load. Finally, we set two globals: $wpf_ac_app_swap: When we swap the wp_fusion()->crm object from Account A to Account B, this global will hold onto Account A until we’re ready to switch back. $wpf_ac_app_switched: This will provide an easy way to check whether we’re connected to Account A or Account B. When we switch to Account B, $wpf_ac_switched is set to “true”. And when we switch back, it’s returned to “false” Determining when to switch function wpf_is_account_two( $user_id ) { $roles = array( ‘deals_contributor’ ); $user = get_userdata( $user_id ); if ( affwp_is_affiliate( $user_id ) ) { return true; } foreach ( $roles as $role ) { if ( ‘deals_contributor’ === $user->role ) { return true; } } return false; } In order to know when the accounts need to be switched, we have this helper function at the top of the plugin. It accepts a user ID, and if the user has a role “deals_contributor”, or if they’re a registered AffiliateWP affiliate, then the user has to go to Account B. If the user doesn’t meet those criteria, the function returns false, and the data is sent to Account A. Switching from Account A to Account B We’ve included add_action()’s for every relevant function in the WPF_User class, and set wpf_maybe_switch_to_account_two() as the callback. These actions are triggered at the start of each function, before any data has been sent. We’ll use this to determine if the account needs to be switched. function wpf_maybe_switch_to_account_two( $user_id ) { global $wpf_ac_app_swap; global $wpf_ac_switched; if( wpf_is_account_two( $user_id ) && $wpf_ac_switched == false ) { // If user should be sent to second app, and the first app is currently active if( $wpf_ac_app_swap == false ) { // If apps haven’t been swapped yet, move first app into swap variable $wpf_ac_app_swap = wp_fusion()->crm->app; // And initialize second app connection wp_fusion()->crm->connect( ACCOUNT_TWO_URL, ACCOUNT_TWO_KEY, true ); } else { // If second app is already saved in the swap, move it to a temp var $temp_second_app = $wpf_ac_app_swap; // Store first app in swap $wpf_ac_app_swap = wp_fusion()->crm->app; // Put second app back into use wp_fusion()->crm->app = $temp_second_app; } // Set $wpf_ac_switched to true to indicate we’re using the second app $wpf_ac_switched = true; } } add_action( ‘wpf_user_register_start’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_get_contact_id_start’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_pre_pull_user_meta’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_get_tags_start’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_apply_tags_start’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_remove_tags_start’, ‘wpf_maybe_switch_to_account_two’ ); add_action( ‘wpf_push_user_meta_start’, ‘wpf_maybe_switch_to_account_two’ ); This function works as follows: We first load up the globals for $wpf_ac_app_swap and $wpf_ac_switched so the function is aware of the current state of things. The function then checks to see if the user in question should be sent to Account B, by calling our wpf_is_account_two() function. It then confirms that $wpf_ac_switched is false. Because if we’ve already switched to Account B somewhere else, we don’t want to do it again. If the user passes those checks, we check the $wpf_ac_app_swap global to see if it’s already been set up and connected to Account B, perhaps because we’ve already swapped the accounts earlier in the registration process. If there’s nothing in the $wpf_ac_app_swap variable, that means we need to set up the new wp_fusion()->crm object and configure it with the Account B API credentials. But first, we move the currently active Account A CRM object into the $wpf_ac_app_swap variable, so it can easily be put back later. Then we call up wp_fusion()->crm->connect() with the Account B connection credentials. After this point, any data sent to the CRM object will now be directed to Account B. On the other hand, if $wpf_ac_app_swap isn’t empty, then we don’t need to initialize the connection all over again. The Account B CRM object is already there waiting for us. We first move the Account B CRM object into a temporary variable so it’s not overwritten. Then we set the $wpf_ac_app_swap to contain the CRM object for Account A, so we can put it back it again later. And finally we set the Account B CRM object we’d stored in the temporary variable. And as the very last step, we set $wpf_ac_switched to “true” to indicate that WP Fusion is now connected to Account B. Switching from Account B back to Account A Switching the accounts back follows the same basic logic in the function above, except we’re now using action hooks that fire at the end of each function, after the data has been sent. The code looks like this: function wpf_maybe_switch_back( $user_id ) { global $wpf_ac_app_swap; global $wpf_ac_switched; if( $wpf_ac_switched == true ) { // If the second app is active, move the first app from the swap to a temp variable $temp_first_app = $wpf_ac_app_swap; // Store second app in swap $wpf_ac_app_swap = wp_fusion()->crm->app; // Put first app back into use wp_fusion()->crm->app = $temp_first_app; // Set $wpf_ac_switched to false $wpf_ac_switched = false; } } add_action( ‘wpf_user_created’, ‘wpf_maybe_switch_back’ ); add_action( ‘wpf_got_contact_id’, ‘wpf_maybe_switch_back’ ); add_action( ‘wpf_user_updated’, ‘wpf_maybe_switch_back’ ); add_action( ‘wpf_tags_modified’, ‘wpf_maybe_switch_back’ ); This should be pretty clear to follow if you’ve read the more detailed walkthrough above. It’s basically […]

Read More

Event Tracking Changelog

[…] – 3/26/2024 Added WooCommerce Order Status Changed event Added subscription ID and parent order ID to WooCommerce Subscriptions events Fixed fatal error when replacing merge tags on the User event type, when the user had array values in their meta Fixed event test button trimming the last character off the event value Fixed empty […]

Read More

Copper Webhooks

[…] are tagged, or automatically update existing users’ meta data and tags when changes happen in Copper. Having trouble receiving webhooks? Check out our troubleshooting guide. Getting Started The “update” method is very straightforward: check the checkbox next to Update Trigger, and any subscriber updates in Copper will automatically be synced back to WordPress. To automatically […]

Read More

Salesforce Enhanced Ecommerce

[…] data as Orders to your Salesforce account for sales made in: WooCommerce Easy Digital Downloads Event Espresso GiveWP Gravity Forms LifterLMS MemberPress and Restrict Content Pro Getting started Once you install the addon, the Enhanced Ecommerce tab will appear in the WP Fusion settings. To begin syncing orders with Salesforce, you must set an account ID for all orders. Once this is set, your new orders will begin syncing into Salesforce automatically. How it works When a customer checks out on your site, WP Fusion will create a new order in Salesforce with the order label, date, and total. The products purchased will be added to the order as items, including their individual prices and quantities. This order will be associated with the contact record who made the purchase. Associating products with Salesforce products When editing any product, download, plan, or membership level in any of the supported Enhanced Ecommerce plugins, you will see a dropdown where you can select an associated Salesforce product. If the product you’re looking for doesn’t appear, click the Refresh Available Tags and Fields button in the WP Fusion settings to update the list. If you don’t select a product, then at checkout WP Fusion will: Attempt to find a product in Salesforce by searching its name and SKU If no match is found, a new product will be created based on the product details in WordPress How it looks Orders appear in Salesforce with their details and order items. Order items are associated with the order and the corresponding pricebook entry. Known limitations Accounts Salesforce requires an Account for all new orders. At the moment, WP Fusion associates all orders with a single account ID (set in the WP Fusion settings). We are exploring options for automatically creating Accounts based on customer data, and this will be included in a future release. Custom fields The integration does not currently support updating custom fields on orders or products (though it is supported via filters, see below). We will make it a priority to find a solution for this in upcoming updates. Pricebooks At the moment WP Fusion just interfaces with the standard pricebook. We will look into adding support for multiple pricebooks in a future update. Modifying the API data WP Fusion supports using filters to modify the data sent to Salesforce with an ecommerce order. The order data can be modified using the wpf_ecommerce_salesforce_add_deal filter. In this example, we overwrite the order title to use a custom title, My custom order title, with the order number. function my_custom_deal_properties( $deal, $order_id ) { /* $deal is structured like: $deal = array( ‘0’ => array( ‘method’ => ‘POST’, ‘url’ => ‘/services/data/v57.0/sobjects/Order’, ‘referenceId’ => ‘orderRef’, ‘body’ => array(, ‘AccountId’ => ‘0013u00001AD9OzAAL’, ‘Name’ => ‘WooCommerce Order #1989’, ‘EffectiveDate’ => ‘2023-06-06’, ‘Status’ => ‘Draft’, ‘Pricebook2Id’ => ’01s6A000001rZ0EQAU’, ‘ShipToContactId’ => ‘0036A0000078r6QQAQ’, ‘BillToContactId’ => ‘0036A0000078r6QQAQ’, ‘CustomerAuthorizedById’ => ‘0036A0000078r6QQAQ’, ), ), ‘1’ => array( ‘method’ => ‘POST’, ‘url’ => ‘/services/data/v57.0/sobjects/OrderItem’, ‘referenceId’ => ‘orderItemRef0’, ‘body’ => array(, ‘OrderId’ => ‘@{orderRef.id}’, ‘PricebookEntryId’ => ’01u3u00000CGLymAAH’, ‘Quantity’ => ‘1’, ‘UnitPrice’ => ‘99.00′, ), ) ) ); */ $deal = ‘My custom order title #’ . $order_id; return $deal; } add_filter( ‘wpf_ecommerce_salesforce_add_deal’, ‘my_custom_deal_properties’, 10, 2 );

Read More

Import Users

WP Fusion includes an import tool that allows you to import existing contacts from your CRM as new WordPress users. To start an import, navigate to the Import Users tab, and select a tag or list in your CRM to use for the import. With the following platforms, you can also import all contacts […]

Read More

User Meta

[…] updates to your CRM, with support for any number of custom fields. Syncing custom fields Any custom fields created on User Meta forms will be displayed in the Contact Fields tab of the WP Fusion settings. You can then map these fields to fields in your CRM, and the data will be synced whenever […]

Read More

WP Ultimo

WP Fusion integrates with WP Ultimo to add customers to your CRM of choice when they purchase a plan. You can also apply tags in your CRM based on the plan purchased and sync site details to custom fields. Tagging When editing any plan in WP Ultimo, you can click on the WP Fusion […]

Read More

Brevo Enhanced Ecommerce

[…] your Brevo account for sales made in: WooCommerce Easy Digital Downloads Event Espresso GiveWP Gravity Forms LifterLMS MemberPress and Restrict Content Pro Getting started Once you install the Enhanced Ecommerce addon, WP Fusion will load your available deal stages from Brevo. You can also refresh the available stages at any time by clicking the Refresh Available Lists & Fields button in the WP Fusion settings. To begin syncing deals with Brevo you must first select a Deal Stage for new deals from the Enhanced Ecommerce tab in the WP Fusion settings. The deal title will be name of the order in WooCommerce (or other supported ecommerce plugin), and the deal value will be set to the total amount of the sale. How it works When a customer checks out on your site, WP Fusion will create a new deal in Brevo with the order label, date, and invoice total. This sale data will be associated with the subscriber record who made the purchase. How it looks WooCommerce orders appear as Deals in Brevo sales pipelines The single deal view shows the title and value, and the deal description contains a list of purchased products and their prices. WooCommerce order statuses If you’re using WooCommerce you can also associate WooCommerce order statuses with deal stages in Brevo. This setting appears under the Enhanced Ecommerce tab in the WP Fusion settings. When the order status is updated in WooCommerce, the deal stage will be updated in Brevo. Warning: It is recommended not to sync Pending payment orders with Brevo. When this is enabled, WP Fusion needs to create a contact record and a deal in Brevo as soon as the pending order is created in WooCommerce, and then update it less than a second later when the payment is processed. This slows down your checkout with many duplicate API calls and in most cases isn’t necessary. A more performant method of tracking incomplete payments is to use Abandoned Cart Tracking. Note: By default, running a WooCommerce Orders (Ecommerce addon) export operation from the Advanced settings tab will only export “paid” orders (Processing or Completed). However, if you have enabled additional order statuses for sync to a Brevo stage, then running the export will process those additional statuses as well. This can be used to export refunded or cancelled orders to Brevo in addition to the paid orders. Modifying the API data WP Fusion supports using filters to modify the data sent to Brevo with an ecommerce order. Custom deal fields At the moment WP Fusion doesn’t have a visual interface for associating WordPress data with custom deal attributes in Brevo. However you can still make this work using the wpf_ecommerce_sendinblue_add_deal filter. In this case we’re going to update the Order URL field, which has an internal name of order_url, and update it with the edit link to a WooCommerce order. function my_custom_deal_properties( $deal, $order_id ) { /* $deal is structured like: $deal = array( ‘name’ => ‘WooCommerce Order #123’, ‘linkedContactsIds’ => array( 123 ), // the contact ID of the customer. ‘attributes’ => array( ‘deal_description’ => ‘Cool Product – $100’, // the products purchased and prices. ‘amount’ => 100, // the total amount. ‘deal_stage’ => ‘Completed’, // the deal stage. ‘close_date’ => ‘2023-05-16′, // the order date. ), ); */ $deal = admin_url( ‘post.php?post=’ . $order_id . ‘&action=edit’ ); // adds a custom attribute. return $deal; } add_filter( ‘wpf_ecommerce_sendinblue_add_deal’, […]

Read More

Zapier Guide

Using this addon with Zapier allows you to trigger Zaps when users register on your site, update their profile, or when a tag is applied or removed. For an example we’ll set up a workflow that triggers an on-site message in Intercom when someone completes a course. Setup Navigate to Settings » WP Fusion and […]

Read More

How To Connect Mautic To WordPress

In this video, you will learn how to install WP Fusion and set up a direct connection to your Mautic account. To get started install and activate the plugin, then navigate to settings -> WP Fusion. Next, go to settings -> WP Fusion And from the ‘Select Your CRM List’ choose ‘Mautic’ Next, we will need to locate pieces of information. Your Mautic URL, Client ID and Client […]

Read More

Logins Overview

The Logins addon for WP Fusion gives you tools for tracking user logins on your site, and performing actions if users meet certain criteria. You can apply tags when a user first logs in, when a user hasn’t logged in for a certain period of time, and perform login redirects based on a […]

Read More

Zoho Enhanced Ecommerce

[…] Zoho account account, for sales made in: WooCommerce Easy Digital Downloads Event Espresso GiveWP Gravity Forms LifterLMS MemberPress and Restrict Content Pro Getting Started Once you install the addon, Deals will automatically be added to Zoho when someone makes a purchase on your site. The default stage for new deals is Closed (Won), but […]

Read More

Creating Custom CRM Modules

WP Fusion can be extended to connect to additional CRMs or o ther contact databases outside of our included integrations. WP Fusion’s integration modules are standardized across all our supported CRMs. Once the integration module is complete, it allows 100+ of the most popular WordPress plugins to communicate bidirectionally with your CRM or marketing […]

Read More

Ontraport Enhanced Ecommerce

[…] transaction data to your Ontraport account for sales made in: WooCommerce Easy Digital Downloads Event Espresso GiveWP Gravity Forms LifterLMS MemberPress and Restrict Content Pro Global Setup There are several global settings for Enhanced Ecommerce with Ontraport. These are found within the WP Fusion settings, on the Enhanced Ecommerce tab. The default settings are appropriate for most stores, but you can change them if needed. Ontraport Pricing WP Fusion can send product prices to Ontraport in two different ways: Use product prices as set in Ontraport: With this setting WP Fusion will just send the ID of the product that was purchased, and Ontraport will calculate the order totals based on the product price that’s set in Ontraport. This is useful if you have a multi-currency store or a store in a different currency than Ontraport supports. For example a product that sells for €100 on your site could be configured in Ontraport with a price of $111. When someone purchases the product, $111 would be recorded on the invoice in Ontraport. Use product prices as paid at checkout: This setting sends the product prices as they’re paid at checkout. With this setting a €100 purchase in WooCommerce would be recorded as a $100 purchase in Ontraport. It also works with discounts, so a $100 purchase in WooCommerce with a 20% off coupon would show as $80 in Ontraport. Shipping Product Ontraport doesn’t currently have an API method for tracking shipping charges. To get around this, WP Fusion can create a pseudo-product named “Shipping” which is added to your invoices and includes the shipping amount paid by the customer. By default WP Fusion will create a new product to record shipping charges automatically during checkout. To disable this feature select Don’t Track Shipping from the dropdown. You can also select a custom product to use to record shipping charges. Taxes By default WP Fusion excludes taxes from product prices sent over the API. However if you sell your products tax-inclusive (for example in Australia) you can select Include in product prices to send the product prices tax-inclusive. Or, optionally, you can select a pre-existing tax object in Ontraport to be used for taxes on your products. Note: If you’ve just created a tax object in Ontraport, click Resynchronize Available Tags and Fields from the Setup tab and reload the page to load the new tax object into the dropdowns. A WooCommerce purchase synced into Ontraport using WP Fusion, using a tax object with a 10% tax rate When a tax object is selected, WP Fusion will send your product prices to Ontraport without tax, and Ontraport will then calculate the tax on the order based on the tax rate set on your tax object. As an example, let’s imagine that we’re selling a Hoodie for $5, and there’s a 10% tax configured in WooCommerce. For each of the options in WP Fusion, the data would show in Ontraport as: Don’t sync taxes: Hoodie: $5 Tax: $0 ($0.50 tax is ignored) Include in product prices: Hoodie: $5.50 ($5 + $0.50 tax) Tax: $0 Existing Ontraport tax object set to 10%: Hoodie: $5 Tax: $0.50 (calculated by Ontraport) Sync Attributes Some WooCommerce extensions (like WooCommerce Product Addons) collect additional information from the customer for certain products. For example a ring could have a custom engraving, or a shirt might have a size and a color. Enabling Sync Attributes will add selected attributes as separate line items to the invoice in Ontraport. It’s recommended to leave this disabled unless you need to see that data in Ontraport. Product Setup After you install the Ecommerce Addon (or update to the latest version), WP Fusion will load a list of all configured products in your Ontraport account. When you go to configure a product in one of our supported ecommerce plugins, you’ll see a new dropdown field where you can link a product on your store with a product already in your Ontraport account. If you don’t already have the products created in Ontraport, don’t worry… WP Fusion will automatically create them for you at the time of checkout, based on the existing details. WP Fusion will intelligently detect variable products in WooCommerce and create additional Ontraport products based on those variations. How it Works When a customer checks out on your site, WP Fusion will create a new transaction in Ontraport with the products purchased, the quantities, and total sale value. This sale data will be tied to the contact record who made the purchase. How it Looks Products dynamically added to the Ontraport products list, including variable products. Purchases will be tracked in Ontraport’s purchase logs and can be used in all reports. You can also view a customer’s purchase history from the Purchases tab within their contact record. Video – Enhanced Ecommerce – Ontraport Refunds If you refund an order in WooCommerce, or change an order’s status to Refunded, the transaction will automatically be updated in Ontraport. Affiliates / referral partners WP Fusion will automatically detect Ontraport partner tracking cookies and will associate them with new orders sent over the API. This will work as long as the oprid cookie is set, which requires Ontraport site tracking to be enabled on your site. When a referral is recorded for an order it will be logged in the WP Fusion logs with a message, “Recording referral for partner ID”. Modifying the API data WP Fusion supports using filters to modify the data sent to Ontraport with an ecommerce order. The filter is wpf_ecommerce_ontraport_add_transaction. Custom affiliate logic As an example, in this snippet we limit affiliate commissions based on the products in the order. /** * Conditionally set the affiliate ID for a transaction. * * @link https://api.ontraport.com/doc/#the-order-object * * @param array $order_data The order data. * @param int $order_id The order ID in WordPress. * @return array The order data. */ function conditionally_set_affiliate( $order_data, $order_id ) { /* $order_data is structured like: $order_data = array( ‘objectID’ => 0, ‘contact_id’ => 123, ‘chargeNow’ => ‘chargeLog’, ‘trans_date’ => 1686818840000, ‘invoice_template’ => 0, ‘delay’ => 0, ‘external_order_id’ => 1234, // order ID in WP. ‘oprid’ => 5, // affiliate ID. ‘offer’ => array( ‘products’ => array( array( ‘name’ => ‘Product name’, ‘id’ => 123, ‘quantity’ => 1, ‘sku’ => ‘SKU’, ), ), ), ); */ // If the order contains a product named “Widget”, disable affiliate referrals. if ( isset( $order_data ) ) { // An […]

Read More

Restricting Access to Content

WP Fusion adds many methods for restricting access to content based on a user’s tags (or “lists” or “segments”) in your connected CRM. These features can be used to create members-only content, drip-feed access to content, and create personalized listings of posts, pages, courses, and more. Not using WP Fusion for access control? You […]

Read More

Jetpack CRM Automatic Imports

Since WP Fusion connects to Jetpack CRM on the same site, it’s not necessary to configure webhooks to enable a bidirectional sync between WP Fusion and Jetpack. Out of the box WP Fusion will: Detect when a Jetpack CRM contact is edited, and sync those changes back to the contact’s WordPress user record (if […]

Read More

wpFusion Flow Event Rules

Would love a brand new plugin from wpFusion (willing to pay extra for it) Idea: maintain a list of rules (like the SNIPPETS PHP plugin does) Each rule has a name The rule is fired WHEN action hook or filter hook is fired (limited to existing wpFusion action hooks and filter events) Add new […]

Read More

The Events Calendar / Event Tickets

WP Fusion integrates with The Events Calendar and Event Tickets by Modern Tribe, letting you add contacts to any one of 50+ supported CRMs and marketing automation platforms, and apply tags when attendees register for events or purchase tickets. You can also track event attendance by syncing check-in data for attendees to a custom field […]

Read More

AffiliateWP

WP Fusion integrates with AffiliateWP to sync affiliates with your CRM or marketing automation tool when they register on your site or update their affiliate profiles, and tag affiliates based on status changes. You can also tag customers when they make a purchase via an affiliate link, and sync referrer metadata to customer contact […]

Read More

MailerLite double opt-ins

[…] subscribers’ opt-in status. Default opt-in status You can configure WP Fusion’s default status for new subscribers at Settings » WP Fusion » General » Default Optin Status. The options are: Default: WP Fusion will not specify an opt-in status for new subscribers. This means subscribers will follow the status you’ve configured in MailerLite— either […]

Read More