setono/sylius-conversion-attribution-plugin

Setono example plugin for Sylius.

Maintainers

Package info

github.com/Setono/sylius-conversion-attribution-plugin

Type:sylius-plugin

pkg:composer/setono/sylius-conversion-attribution-plugin

Transparency log

Fund package maintenance!

Setono

Statistics

Installs: 9 271

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v1.1.0 2025-07-09 10:26 UTC

README

Latest Version Software License Build Status Code Coverage Mutation testing

See where customers are coming from by attributing conversions directly in your Sylius store

Installation

Download plugin

composer require setono/sylius-conversion-attribution-plugin

Notice that this also installs the setono/client-bundle which is required by this plugin to work properly.

If you want to use the default javascript injection, you should also install the setono/tag-bag-bundle.

See the installation instructions for the setono/tag-bag-bundle here.

Import routes

# config/routes/setono_sylius_conversion_attribution.yaml

setono_sylius_conversion_attribution:
    resource: "@SetonoSyliusConversionAttributionPlugin/Resources/config/routes.yaml"

Extend Customer and Order entities

<?php

declare(strict_types=1);

namespace App\Entity\Customer;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusConversionAttributionPlugin\Model\CustomerInterface;
use Setono\SyliusConversionAttributionPlugin\Model\CustomerTrait;
use Sylius\Component\Core\Model\Customer as BaseCustomer;

/**
 * @ORM\Entity
 *
 * @ORM\Table(name="sylius_customer")
 */
class Customer extends BaseCustomer implements CustomerInterface
{
    use CustomerTrait;
}
<?php

declare(strict_types=1);

namespace App\Entity\Order;

use Doctrine\ORM\Mapping as ORM;
use Setono\SyliusConversionAttributionPlugin\Model\OrderInterface;
use Setono\SyliusConversionAttributionPlugin\Model\OrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;

/**
 * @ORM\Entity
 *
 * @ORM\Table(name="sylius_order")
 */
class Order extends BaseOrder implements OrderInterface
{
    use OrderTrait;
}

Migrate your database

php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Prune old sources (recommended)

Every tracked hit creates a source row, so the table grows continuously. Schedule the prune command (for example daily via cron) to delete old rows. By default it keeps 180 days:

php bin/console setono:sylius-conversion-attribution:prune

Notes

Optional runtime dependencies

  • The default JavaScript injection requires setono/tag-bag-bundle. Without it, enabling the javascript feature throws at container build time. Install it, or set setono_sylius_conversion_attribution.javascript.enabled: false and inject the tracking snippet yourself.
  • Bot filtering (both for the injected snippet and the /track endpoint) is provided by setono/bot-detection-bundle, which is installed automatically as a dependency.

Full page cache

The injected tracking snippet embeds a server-resolved client id. If a full page / HTTP cache stores the rendered HTML, every visitor served that cached page shares the same embedded client id, which corrupts attribution. Exclude pages carrying the snippet from full page caching, or only enable the feature on responses that are not cached.

Privacy / GDPR

A source row stores the visitor's IP address and user agent, which are personal data in many jurisdictions. Keep retention short by scheduling the prune command, and ensure your privacy policy and consent handling cover this collection (you may need to anonymize or omit the IP depending on your requirements).