setono/sylius-google-ads-plugin

Sylius 的 Google Ads 插件。

资助包维护!
Setono

安装次数: 26,759

依赖关系: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放性问题: 2

类型:sylius-plugin

v2.0.0 2024-09-17 07:04 UTC

README

Latest Version Software License Build Status

此插件跟踪 Sylius 商店的转换。它使用 Google Ads API 而不是默认的 JavaScript 跟踪来实现。这样做有几个好处

  • 更容易控制特定用户的同意状态
  • 更容易更改订单的实际价值
  • 你的页面上没有用于跟踪 Google Ads 的 JavaScript,这意味着页面加载更快
  • 你可以决定你的 cookie 的 ttl,而不是苹果和他们的 ITP
  • 没有因广告拦截器而丢失跟踪的风险

安装

步骤 1: 安装 gRPC

此插件内部使用 google-ads-php。为了正确使用该库,建议安装 gRPC PHP 扩展。只需运行 pecl install grpc 并在 php.ini 中通过添加 extension=grpc.so 启用扩展即可。

步骤 2: 安装并启用插件

composer require setono/sylius-google-ads-plugin

config/bundles.php 中将捆绑包添加到 SyliusGridBundle 之前

<?php
# config/bundles.php

return [
    // ...
    
    Setono\SyliusGoogleAdsPlugin\SetonoSyliusGoogleAdsPlugin::class => ['all' => true], // Added before the grid bundle
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    
    // ...
];

步骤 3: 添加配置

# 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"

步骤 4: 创建迁移文件

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

步骤 5: 设置 cron 作业

第一个 cron 作业将处理 Google Ads 转换。定期运行此 cron 作业,例如每 5 分钟一次

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

下一个 cron 作业将修剪转换表。根据需要运行此作业,可能是每天一次

php bin/console setono:sylius-google-ads:prune-conversions

步骤 6: 将 Messenger 命令映射到异步传输(可选,但推荐)

该插件使用 Symfony Messenger 发送消息(ProcessConversion),这将触发转换的处理。如果您想异步执行此操作,可以在您的 messenger 配置中执行以下操作

framework:
    messenger:
        transports:
            async: '%env(MESSENGER_TRANSPORT_DSN)%'
        routing:
            'Setono\SyliusGoogleAdsPlugin\Message\Command\CommandInterface': async

这会将实现该接口的所有消息映射到 async 传输。

现在插件已安装。请阅读下一节了解如何在您的商店中使用它。

用法

要开始使用此插件,请转到 https://your-domain.com/admin/google-ads 并按照说明操作。