setono / sylius-google-ads-plugin
Google Ads plugin for Sylius.
Fund package maintenance!
Setono
Installs: 27 725
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 0
Open Issues: 3
Type:sylius-plugin
Requires
- php: >=8.1
- brick/phonenumber: ^0.5.0
- doctrine/collections: ^1.6
- doctrine/dbal: ^2.13 || ^3.8
- doctrine/orm: ^2.7
- doctrine/persistence: ^1.3 || ^2.2 || ^3.2
- google/auth: ^1.26
- google/gax: ^1.19
- googleads/google-ads-php: ^24.0
- knplabs/knp-menu: ^3.1
- ocramius/doctrine-batch-utils: ^2.4
- psr/event-dispatcher: ^1.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- setono/composite-compiler-pass: ^1.1
- setono/doctrine-orm-trait: ^1.0
- sylius/channel: ^1.0
- sylius/channel-bundle: ^1.0
- sylius/core: ^1.0
- sylius/core-bundle: ^1.0
- sylius/order: ^1.0
- sylius/resource-bundle: ^1.6
- sylius/ui-bundle: ^1.0
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/event-dispatcher: ^6.4 || ^7.0
- symfony/event-dispatcher-contracts: ^2.5 || ^3.3
- symfony/form: ^6.4 || ^7.0
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/messenger: ^6.4 || ^7.0
- symfony/options-resolver: ^6.4 || ^7.0
- symfony/routing: ^6.4 || ^7.0
- symfony/string: ^6.4 || ^7.0
- symfony/validator: ^6.4 || ^7.0
- symfony/workflow: ^6.4 || ^7.0
- twig/twig: ^2.15 || ^3.4
- webmozart/assert: ^1.11
Requires (Dev)
- api-platform/core: ^2.7.18
- babdev/pagerfanta-bundle: ^3.8
- behat/behat: ^3.14
- doctrine/doctrine-bundle: ^2.10
- jms/serializer-bundle: ^4.2
- lexik/jwt-authentication-bundle: ^2.17
- matthiasnoback/symfony-config-test: ^4.3 || ^5.1
- phpunit/phpunit: ^9.6
- psalm/plugin-phpunit: ^0.18
- setono/client-bundle: ^1.0@beta
- setono/code-quality-pack: ^2.8.2
- shipmonk/composer-dependency-analyser: ^1.7
- sylius/sylius: ~1.12.19
- symfony/debug-bundle: ^6.4 || ^7.0
- symfony/dotenv: ^6.4 || ^7.0
- symfony/intl: ^6.4 || ^7.0
- symfony/serializer: ^6.4 || ^7.0
- symfony/web-profiler-bundle: ^6.4 || ^7.0
- symfony/webpack-encore-bundle: ^1.17
- weirdan/doctrine-psalm-plugin: ^2.9
- willdurand/negotiation: ^3.1
- 2.x-dev
- v2.0.0
- v2.0.0-beta.6
- v2.0.0-beta.5
- v2.0.0-beta.4
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta
- v2.0.0-alpha.13
- v2.0.0-alpha.11
- v2.0.0-alpha.10
- v2.0.0-alpha.9
- v2.0.0-alpha.8
- v2.0.0-alpha.6
- v2.0.0-alpha.5
- v2.0.0-alpha.4
- v2.0.0-alpha.3
- v2.0.0-alpha
- 1.x-dev
- v1.0.1
- v1.0.0
- v1.0.0-alpha.8
- v1.0.0-alpha.7
- v1.0.0-alpha.6
- v1.0.0-alpha.5
- v1.0.0-alpha.4
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha
- v0.1.1
- v0.1.0
This package is auto-updated.
Last update: 2024-12-17 07:41:53 UTC
README
This plugin tracks conversions in your Sylius store. It's done with the Google Ads API instead of the default javascript tracking. It has a few benefits to do this:
- Easier to control the consent status for a given user
- Easier to change the value of an order after the fact
- No javascripts on your page to track Google Ads, which means faster page load
- You decide the ttl on your cookies, not Apple and their ITP
- No risk of losing tracking because of ad blockers
Installation
Step 1: Install gRPC
Internally this plugin uses the google-ads-php. To use that library properly
it's advised to install the gRPC PHP extension. It should work by just running pecl install grpc
and enabling the extension
in your php.ini
by adding extension=grpc.so
.
Step 2: Install and enable plugin
composer require setono/sylius-google-ads-plugin
Add the bundle to your config/bundles.php
before the SyliusGridBundle
:
<?php # config/bundles.php return [ // ... Setono\SyliusGoogleAdsPlugin\SetonoSyliusGoogleAdsPlugin::class => ['all' => true], // Added before the grid bundle Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
Step 3: Add configuration
# config/packages/setono_sylius_google_ads.yaml imports: - "@SetonoSyliusGoogleAdsPlugin/Resources/config/app/config.yaml"
# config/routes/setono_sylius_google_ads.yaml setono_sylius_google_ads: resource: "@SetonoSyliusGoogleAdsPlugin/Resources/config/routes.yaml"
Step 4: Create migration file
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Step 5: Set up cronjobs
The first cronjob will process Google Ads conversions. Run this cronjob regularly, e.g. every 5 minutes:
php bin/console setono:sylius-google-ads:process-conversions
The next cronjob will prune the conversions table. Run this job as often as you'd like, maybe daily:
php bin/console setono:sylius-google-ads:prune-conversions
Step 6: Map the Messenger command to an async transport (optional, but recommended)
The plugin uses the Symfony Messenger to dispatch a message (ProcessConversion
) which will trigger the processing
of a conversion. If you want to do this asynchronously, you can do something like the following in your messenger config:
framework: messenger: transports: async: '%env(MESSENGER_TRANSPORT_DSN)%' routing: 'Setono\SyliusGoogleAdsPlugin\Message\Command\CommandInterface': async
This maps all messages implementing that interface to the async
transport.
Now the plugin is installed. Please read the next section to learn how to use it in your store.
Usage
To start using the plugin, go to https://your-domain.com/admin/google-ads and follow the instructions.