Integration with Magento 2
Read this article in Ukrainian ā®
The eSputnik 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 module's name is Yespo, and the section it adds to the Magento admin is called Yespo CDP, but it works with eSputnik accounts the same way.
- 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.
- An eSputnik 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, andevents.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:flushIn production mode also deploy static content as usual with bin/magento setup:static-content:deploy.
NoteThe module is published on Packagist, and Composer takes its
magento/*dependencies fromrepo.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 inauth.jsonin the Magento root or in~/.composer/: without themcomposer requirestops with the401 Unauthorizederror.
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 yespoThe 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
-
Create an API key with the Full access to API permission in your eSputnik account.
-
In the Magento admin, open Stores ā Configuration ā Yespo CDP or the Yespo CDP menu item.

-
Select the Website to connect. The field appears only when the installation has more than one website.
-
Enter the API Key and click Connect.

-
Wait until the Account connection, Web tracking setup, and Web push setup rows report success.
-
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 connection | The key is valid and the website is connected. The row also holds the Disable integration button. |
| Web tracking setup | The storefront domain is registered in eSputnik and the site script is installed on every storefront page. |
| Web push setup | The Web Push domain is registered and the Service Worker is installed for this website. |
| Data sync | The state of contact and order synchronization, the Enable and Disable buttons, and the counters. |

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.

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 eSputnik. 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 eSputnik. Below, a customer is the record in the store, and a contact is the record in the eSputnik account.
Real-Time Sync
Magento event | Result in eSputnik |
|---|---|
| A customer is created or saved | The contact is created or updated |
| A customer address is saved or deleted | The contact's address and phone number are updated |
| A customer is deleted | The contact is deleted in the mode selected in Contact Deletion Mode |
| Customers are imported through System ā Data Transfer ā Import | Imported 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 eSputnik, 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 eSputnik rejects is counted as failed and the reason goes to the log, while the rest of the batch is imported.

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 Attribute | The 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 Mode | Manual Delete removes the contact in eSputnik 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 eSputnik. Permanent erasure is limited per hour, and the deletions above the limit wait for the next hour. Magento orders are not changed either way. |

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
eSputnik field | Magento source |
|---|---|
| External customer ID | Customer ID |
| First name, last name | Customer first and last name, cut to 40 characters. A name with no letters is left out, because eSputnik rejects such a value |
| Customer email address | |
| Phone number | The configured attribute or the default address |
| Address, town, region, postcode, country | The selected customer address |
| Language, time zone | Store 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 | eSputnik status |
|---|---|
| pending, pending_payment, holded, payment_review | INITIALIZED |
| processing | IN_PROGRESS |
| complete, closed | DELIVERED |
| canceled, fraud | CANCELLED |
| Any other status | The order is not sent |

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.

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 eSputnik into var/log/yespo_cdp.log. Request bodies are never written, but API error lines start carrying eSputnik'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.

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 eSputnik 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 eSputnik, 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 move | The queue consumers, and first of all the cron line for the consumers group |
| An import session is not found after reconnecting | A 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 not | The same cause: the consumer has not picked up the configuration change |
| More than one consumer process runs on one queue topic | The 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 eSputnik ā the data that has already been sent stays in the account. Deleting a Web Push domain in eSputnik 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:disableTo 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.jsonThe 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:
-
Click Disable integration if the store is connected.
-
Disable the module and drop its tables while the code is still in place:
bin/magento module:disable Yespo_Cdp bin/magento setup:upgrade -
Delete the
app/code/Yespo/Cdpfolder. Do not delete it before step 2: without itsdb_schema_whitelist.jsonMagento keeps the tables. -
Run
bin/magento setup:upgradeagain, thenbin/magento cache:flush. In production mode also runbin/magento setup:di:compileandbin/magento setup:static-content:deploy. -
Remove the
yespo.*queue consumers from your systemd units or from thecron_consumers_runnerlist inapp/etc/env.php.
Updated about 2 hours ago