Integration with Magento 2

The Yespo module for Magento 2 automatically handles the following technical setup:

  • Contact transfer — real-time customer creation, update, and deletion, plus a historical import of the customer base.
  • Order transfer — real-time order creation and status changes, plus a historical import of the order history.
  • Web tracking — site script installation and event sending (see the full list of events below).
  • Web Push — domain registration and Service Worker setup. You do not need to follow the steps from the standard Web Push setup guide — the only remaining step is to activate Web Push in your organization settings.
📘

Note

  • The integration is connected for one Magento website. Contacts and orders of the other websites in the installation are not sent. Shared customer accounts are the exception: with Global selected in Stores → Configuration → Customers → Customer Configuration → Account Sharing Options, a customer of any website can shop on the connected one, so contacts are sent from every website. Orders and web tracking stay within the connected website.
  • The module registers the domain of the connected website's default store view. The site script runs on every store view of that website, while Web Push works on that one domain only: store views on other domains need a separate account.
  • Everything the module sends after the connection goes through the Magento message queue, so the queue consumers have to be running.
  • Technical details about the module are in the public repository.

Requirements

  • Magento Open Source 2.4.4–2.4.9 and the PHP version your Magento version requires, from 8.1 to 8.5.
  • A Yespo account and an API key with the Full access to API permission — see API Keys.
  • Magento cron running every minute.
  • Outbound HTTPS access from the server to api.yespo.io, tracker.yespo.io, and events.yespo.io.

Installation

Run these commands from the Magento root:

composer require yespo/module-cdp
bin/magento module:enable Yespo_Cdp
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

In production mode also deploy static content as usual with bin/magento setup:static-content:deploy.

📘

Note

The module is published on Packagist, and Composer takes its magento/* dependencies from repo.magento.com, which requires Adobe Commerce Marketplace access keys (My Profile → Access Keys). A store installed through Composer usually has them already. If it does not, save the keys in auth.json in the Magento root or in ~/.composer/: without them composer require stops with the 401 Unauthorized error.

The module can also be installed by hand: copy it to app/code/Yespo/Cdp and run the same bin/magento commands.

Check the result:

bin/magento setup:db:status
bin/magento queue:consumers:list | grep yespo

The first command reports that all modules are up to date. The second one lists seven consumers. The module adds its own tables and does not change the core ones.

Connecting the Store

  1. Create an API key with the Full access to API permission in your Yespo account.

  2. In the Magento admin, open Stores → Configuration → Yespo CDP or the Yespo CDP menu item.

    Magento configuration sidebar with the Yespo CDP section expanded, showing Data synchronization, Contacts sync, Orders sync, Web tracking, and System settings
  3. Select the Website to connect. The field appears only when the installation has more than one website.

  4. Enter the API Key and click Connect.

    Yespo Customer Data Platform section with the store selector, the API Key field, and the Connect button
  5. Wait until the Account connection, Web tracking setup, and Web push setup rows report success.

  6. Flush the cache in System → Cache Management, at least Full Page Cache, so the pages that are already cached pick up the site script.

The page then shows the state of each step:

Row
What it covers
Account connectionThe key is valid and the website is connected. The row also holds the Disable integration button.
Web tracking setupThe storefront domain is registered in Yespo and the site script is installed on every storefront page.
Web push setupThe Web Push domain is registered and the Service Worker is installed for this website.
Data syncThe state of contact and order synchronization, the Enable and Disable buttons, and the counters.
Account connection, Web tracking setup, and Web push setup rows with green check marks and the Disable integration button

If a step fails, the module repeats it several times and then offers Try again, which re-runs only that step, and Contact Support. The API key is stored encrypted and is not shown again after saving.

Invalid API key message and the Web push setup row showing an error with the Contact support and Try again buttons

Queue Consumers

Contacts, orders, and server-side tracking events are published to the Magento message queue, and a queue consumer — the process Magento starts with bin/magento queue:consumers:start — sends them to Yespo. Until the consumers are running, the counters in the Data sync row do not move and nothing reaches the account. The module needs seven consumers, and all of them have the yespo. prefix in the output of bin/magento queue:consumers:list.

Magento cron has to run every minute: Magento then starts the consumers itself through the consumers_runner job. The job lives in the consumers cron group, which runs as a separate process, and Magento starts that process by itself, so the usual crontab line with bin/magento cron:run is enough and no separate line for the consumers group is needed.

Setup is needed only where the standard behaviour has been changed. If cron_consumers_runner/consumers in app/etc/env.php lists specific consumers, add the seven names with the yespo. prefix to that list. If cron_run there is false, or the server does not let PHP start processes, run the consumers with your process manager.

A consumer that stops is started again on the next cron run. For higher volumes the consumers are kept as separate system services so that they restart within seconds: the parameters of such a setup are described in the module repository. The two ways of running the consumers are not combined, because the same messages would be processed twice.

Contact Sync

A Magento customer becomes a contact in Yespo. Below, a customer is the record in the store, and a contact is the record in the Yespo account.

Real-Time Sync

Magento event
Result in Yespo
A customer is created or savedThe contact is created or updated
A customer address is saved or deletedThe contact's address and phone number are updated
A customer is deletedThe contact is deleted in the mode selected in Contact Deletion Mode
Customers are imported through System → Data Transfer → ImportImported customers are created or updated, and the deleted ones are removed in the mode selected in Contact Deletion Mode

Historical Import

Click Enable in the Data sync row to import the existing customer base. The module reads the customers of the connected website page by page and sends them to Yespo, which matches them by customer identifier, email address, and phone number, so an existing contact is updated instead of being duplicated. The order import starts right after the contact one.

The Data sync row shows the Total, Synchronized, Successful, and Failed counters for contacts and orders. A contact that Yespo rejects is counted as failed and the reason goes to the log, while the rest of the batch is imported.

Data sync row set to Enabled with the Disable button and the Total, Synchronized, Successful, and Failed counters for contacts and orders

Disable only pauses the synchronization: the integration stays connected, and the changes made while it is off are recorded and sent when you enable it again.

Contact Sync Settings

Setting
Description
Phone AttributeThe customer attribute the phone number is taken from. Only this attribute is sent. Select Use Default Address Phone Number to take the number from the default billing address or, if it has none, from the default shipping address. A customer with no value in the attribute is synced without a phone number.
Contact Deletion ModeManual Delete removes the contact in Yespo but keeps it linked to its orders, so it can be restored. GDPR Erase permanently removes the contact's personal data and anonymizes its orders in Yespo. Permanent erasure is limited per hour, and the deletions above the limit wait for the next hour. Magento orders are not changed either way.
Sync settings section with the Phone Attribute and Contact Deletion Mode fields

Phone Attribute is locked once the historical import has started. To change it, disconnect the store and connect it again.

The module sends the phone number as Magento holds it: every character except digits and a leading plus is removed, a plus inside the number is dropped, and a value with no digits is not sent. The module never adds, replaces, or validates the country calling code.

Which Customer Data Is Sent

Yespo field
Magento source
External customer IDCustomer ID
First name, last nameCustomer first and last name, cut to 40 characters. A name with no letters is left out, because Yespo rejects such a value
EmailCustomer email address
Phone numberThe configured attribute or the default address
Address, town, region, postcode, countryThe selected customer address
Language, time zoneStore locale and time zone

Order Sync

Orders placed on the storefront and orders created in the admin are both sent, together with every change of their status. The order history is imported once, right after the contact import, and its counters are shown in the same Data sync row.

Which Order Data Is Sent

An order carries its order number, the customer identifier for a registered customer, the status and its label, the total, currency, and creation date, the customer email address, phone number, and name, the delivery address, the delivery and payment method, and the shipping, discount, and tax amounts.

Order items carry the identifier of the simple product: a configurable product is sent as the variant that was bought, and a bundle is sent as its component products with the bundle price spread over them. Besides that, an item carries its name, the quantity ordered, the price with the line discount applied, the deepest assigned category, the links to the product page and image, and a description built from the selected options. Custom option text and uploaded files are not sent.

Order Status Mapping

Magento status
Yespo status
pending, pending_payment, holded, payment_reviewINITIALIZED
processingIN_PROGRESS
complete, closedDELIVERED
canceled, fraudCANCELLED
Any other statusThe order is not sent
Order statuses mapping table with Magento statuses on the left and Yespo statuses on the right

An order whose status is not in the table is skipped as a whole. The module does not count the skip as a failure and does not repeat it, and a mapping saved after the skip applies to the following status changes.

The mapping is edited in the Orders sync section, and Save stores it without enabling Data sync. Every row is editable until the first Enable; after it, the saved rows are read-only, and switching Data sync off does not unlock them. Rows left unmapped stay editable, and become read-only once you save them. To change a saved mapping, disconnect the store and connect it again.

Web Tracking

Web tracking sends the behaviour data that segmentation, product recommendations, and abandoned cart workflows are built on. It works as soon as the site script is installed, independently of Data sync.

Enable Web Tracking in the Web tracking section is the master switch, and each event below it has its own switch.

Events section with the Enable Web Tracking switch and the switches for the CustomerData, StatusCart, PurchasedItems, CategoryPage, SearchRequest, and AddToWishlist events

The site script sends the views of the home page, category page, product page, cart page, and 404 page, a search that returns no results, and the data a visitor types at checkout, in the registration form, or in the login form. For a configurable product the script sends the cheapest available variant and sends the event again when the visitor selects options.

The module sends the cart status, the purchased items, the customer data, and the products added to the wishlist from the server. A server event is sent only when the Magento request behind it carried the site script's sc cookie. Prices follow the tax display setting of the store. A server event that fails is written to the log and dropped: unlike contacts and orders, tracking events are not sent again.

System Settings

The System settings tab holds the module's service options. All fields apply to the whole installation.

Reset System Settings — the Reset to Defaults button returns every value on the tab to its initial state. It applies at once, with no separate save, and leaves the API key and the Data sync state untouched.

Enable Debug Logging writes the method and the URL of every request to Yespo into var/log/yespo_cdp.log. Request bodies are never written, but API error lines start carrying Yespo's response, which can hold submitted values such as an email address. The log file is not restricted by admin roles, so turn this on while you diagnose an issue and off afterwards.

Clean Config Cache Automatically cleans the Magento configuration cache when the integration is paused or resumed and when Data sync is switched on or off, so the storefront acts on the new state at once. With the option off, flush the cache yourself in System → Cache Management after each such change: until then the storefront acts on the previous state, and contact changes can be recorded or sent later than you expect.

Bulk Sync Batch Size in the Advanced: Contacts sync and Advanced: Orders sync sections sets how many records the module sends in one request during the historical import. The maximum is 2000 contacts and 1000 orders; larger values are capped at those. An import that is already running keeps the size it started with.

System settings tab with the Reset to Defaults button, the Enable Debug Logging and Clean Config Cache Automatically fields, and the Advanced: Contacts sync and Advanced: Orders sync sections with their batch sizes

Command Line Tools

bin/magento yespo:sync:customers [--batch-size=N]
bin/magento yespo:sync:orders [--batch-size=N] [--from-date=Y-m-d]

Both commands start the same historical import as the Enable and Try again buttons: they publish queue messages, and the consumers do the sending. --from-date limits the order import to the orders created on or after that date.

Admin Permissions

Access to each section of the module is granted to an admin role separately in System → Permissions → User Roles → Role Resources → Yespo CDP → Integration Configuration: the Data synchronization, Contacts sync, Orders sync, Web tracking, and System settings sections, and the Disable integration action.

How the Module Recovers from Errors

  • A request that Yespo answers with a temporary error is repeated on a schedule.
  • A request rejected because of its content is not repeated: the reason goes to the log, and a failed import batch stays failed until you click Try again.
  • An invalid or revoked key disables the integration, and an admin notice asks you to connect with a valid one. When the same key works again, the integration is enabled automatically.
  • After several failed requests in a row the data transfer is paused. A scheduled job checks Yespo, enables the transfer again, and queues the customers and orders that changed during the pause.
  • An import batch that stays unresolved is marked as failed automatically, so the import does not hang.
  • A growing queue backlog and a missing consumer are reported by admin notices, which disappear once the cause is gone.

Logging and Troubleshooting

The module writes its own log to var/log/yespo_cdp.log. Every request carries a short identifier that is repeated in the error lines of the same call, so one call can be followed through the log. The API key and the request bodies are never written there.

Enable Debug Logging in the System settings section adds the method and the address of every request and the response body of API errors. Turn it on only while you diagnose a problem and turn it off afterwards, because a response body can contain the values that were sent, such as an email address.

Symptom
What to check
The counters in Data sync never moveThe queue consumers, and first of all the cron line for the consumers group
An import session is not found after reconnectingA running consumer still holds the previous API key — restart the consumers
The name and email address of a contact are updated, but the language and time zone are notThe same cause: the consumer has not picked up the configuration change
More than one consumer process runs on one queue topicThe system service has no stop command, so a restart left a duplicate process

Disconnecting and Uninstalling

Disable integration returns the store to the state it had before the connection: it deletes the saved settings of the module in all scopes, clears its tables, removes the messages still waiting in the queue, deletes the Web Push Service Worker and the local log, and flushes the caches.

The action never deletes anything in Yespo — the data that has already been sent stays in the account. Deleting a Web Push domain in Yespo would also drop its subscribers, so disabling the module does not do that.

Removing a Module Installed with Composer

Run bin/magento module:uninstall Yespo_Cdp -r — the command removes the Composer package as well.

If the command stops at the Removing code from Magento codebase: line and does not finish, Composer is waiting for an answer that Magento does not show. Magento runs Composer with its own home directory, var/composer_home, and does not see the repo.magento.com keys, which usually live only in ~/.composer/auth.json — this is a known Magento issue. The module data is already removed at this point, so stop the command with Ctrl+C and finish the removal by hand:

composer remove yespo/module-cdp
bin/magento setup:upgrade
bin/magento cache:flush
bin/magento maintenance:disable

To keep the command from stopping next time, copy your Composer keys to where Magento looks for them. Run this from the Magento root:

mkdir -p var/composer_home
cp "$(composer config --global home)/auth.json" var/composer_home/auth.json
chmod 600 var/composer_home/auth.json

The file holds secrets, so keep it out of the repository. To see the error itself instead of a stop, run the command as COMPOSER_NO_INTERACTION=1 bin/magento module:uninstall Yespo_Cdp -r.

Removing a Module Copied into app/code

A module copied into app/code by hand is not removed by module:uninstall. For it:

  1. Click Disable integration if the store is connected.

  2. Disable the module and drop its tables while the code is still in place:

    bin/magento module:disable Yespo_Cdp
    bin/magento setup:upgrade
  3. Delete the app/code/Yespo/Cdp folder. Do not delete it before step 2: without its db_schema_whitelist.json Magento keeps the tables.

  4. Run bin/magento setup:upgrade again, then bin/magento cache:flush. In production mode also run bin/magento setup:di:compile and bin/magento setup:static-content:deploy.

  5. Remove the yespo.* queue consumers from your systemd units or from the cron_consumers_runner list in app/etc/env.php.


Did this page help you?