setono / sylius-google-ads-plugin
Google Ads plugin for Sylius.
Installs: 18 381
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 3
Type:symfony-bundle
Requires
- php: >=7.4
- ext-hash: *
- ext-mbstring: *
- doctrine/collections: ^1.6
- doctrine/orm: ^2.7
- doctrine/persistence: ^1.3 || ^2.2
- knplabs/knp-menu: ^3.1
- psr/event-dispatcher: ^1.0
- setono/doctrine-object-manager-trait: ^1.0
- setono/symfony-main-request-trait: ^1.0
- sylius/resource-bundle: ^1.6
- symfony/config: ^4.4 || ^5.4
- symfony/console: ^4.4 || ^5.4
- symfony/dependency-injection: ^4.4 || ^5.4
- symfony/event-dispatcher: ^4.4 || ^5.4
- symfony/form: ^4.4 || ^5.4
- symfony/http-foundation: ^4.4 || ^5.4
- symfony/http-kernel: ^4.4 || ^5.4
- twig/twig: ^2.14
- webmozart/assert: ^1.10
Requires (Dev)
- api-platform/core: ^2.6
- friendsofsymfony/oauth-server-bundle: >2.0.0-alpha.0 ^2.0@dev
- lexik/jwt-authentication-bundle: ^2.16
- matthiasnoback/symfony-config-test: ^4.3
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.17
- psalm/plugin-symfony: ^3.1
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.2
- sylius/admin-api-bundle: ^1.11
- sylius/sylius: ~1.10.14
- symfony/debug-bundle: ^4.4 || ^5.4
- symfony/dotenv: ^4.4 || ^5.4
- symfony/intl: ^4.4 || ^5.4
- symfony/web-profiler-bundle: ^4.4 || ^5.4
- symfony/webpack-encore-bundle: ^1.15
- weirdan/doctrine-psalm-plugin: ^2.3
This package is auto-updated.
Last update: 2023-02-08 11:22:52 UTC
README
This plugin tracks conversions in your Sylius store. It's done with offline conversion tracking 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 a given order after the fact
- No javascripts on your page to track Google Ads, which means faster page load
Installation
Step 1: 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 2: 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"
That's it!
Usage
Offline conversion tracking works like this:
- We collect the
gclid
query parameter when a user enters the store from clicking on an ad. We save this value in a cookie. - When the same user completes a purchase, we will insert a new row into our
conversion
table. - We then expose these conversions as CSV data on a URL that you grab in the backend. This URL is then used when setting up the conversion action inside the Google Ads interface.
Step 1: Set up a new conversion action in Sylius
-
Go to
/admin/conversion-actions/new
and create a new conversion action. There's a help text on the right explaining how to do it. -
When you have created your conversion, you go to the conversion action index (
/admin/conversion-actions/
) where you find the URL you need to give to Google. It will look something like:https://your-domain.com/en_US/google-ads/conversions/af5717388cb5a610b92c9da43914384cfa8a491e5999e4e9c4e9e0b32204b0dc
Step 2: Set up a matching conversion action in Google Ads
- Create a new conversion action inside the Google Ads interface.
- Name it the same as you did in Sylius. This is important since Google matches the name.
- Create a new upload of conversions. See the image below:
Advanced usage
Conversions have a state property, which is ready
by default. This means that purchase conversions will be downloaded
by Google when a customer has completed an order. This is not always the intended behavior. Sometimes it's more likely
that the conversion should first be counted when the order is paid. To fix this, edit the configuration:
# config/packages/setono_sylius_google_ads.yaml setono_sylius_google_ads: default_conversion_states: purchase: !php/const Setono\SyliusGoogleAdsPlugin\Model\ConversionInterface::STATE_PENDING
and run this command periodically:
$ php bin/console setono:sylius-google-ads:process-pending-conversions