Google Ads plugin for Sylius.

Installs: 18 381

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 3


v1.0.1 2022-11-08 10:46 UTC


Latest Version Software License Build Status

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


Step 1: Install and enable plugin

$ composer require setono/sylius-google-ads-plugin

Add the bundle to your config/bundles.php before the SyliusGridBundle:

# 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
    - "@SetonoSyliusGoogleAdsPlugin/Resources/config/app/config.yaml"
# config/routes/setono_sylius_google_ads.yaml
    resource: "@SetonoSyliusGoogleAdsPlugin/Resources/config/routes.yaml"

That's it!


Offline conversion tracking works like this:

  1. We collect the gclid query parameter when a user enters the store from clicking on an ad. We save this value in a cookie.
  2. When the same user completes a purchase, we will insert a new row into our conversion table.
  3. 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

  1. 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.

  2. 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:

Step 2: Set up a matching conversion action in Google Ads

  1. Create a new conversion action inside the Google Ads interface.
  2. Name it the same as you did in Sylius. This is important since Google matches the name.
  3. Create a new upload of conversions. See the image below:

Upload conversions

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
        purchase: !php/const Setono\SyliusGoogleAdsPlugin\Model\ConversionInterface::STATE_PENDING

and run this command periodically:

$ php bin/console setono:sylius-google-ads:process-pending-conversions