Google Ads plugin for Sylius.
- Easier to control the consent status for a given user
- Easier to change the value of a given order after the fact
$ composer require setono/sylius-google-ads-plugin
Add the bundle to your
config/bundles.php before the
<?php # config/bundles.php return [ // ... Setono\SyliusGoogleAdsPlugin\SetonoSyliusGoogleAdsPlugin::class => ['all' => true], // Added before the grid bundle Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
# 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"
Offline conversion tracking works like this:
- We collect the
gclidquery 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
- 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.
/admin/conversion-actions/newand 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:
- 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:
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. Some times 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