setono/sylius-analytics-plugin

Google Analytics plugin for Sylius

Fund package maintenance!
Setono

Installs: 220 358

Dependents: 0

Suggesters: 0

Security: 0

Stars: 20

Watchers: 3

Forks: 13

Open Issues: 2

Type:sylius-plugin

v4.0.0-alpha.1 2023-03-28 10:52 UTC

README

Latest Version Software License Build Status

This plugin adds Google Analytics tracking to your store. It injects the tags directly and hence does not depend on third party tools like Google Tag Manager.

Installation

Step 1: Download the plugin

This plugin uses the TagBagBundle to inject scripts onto your page. Please install that bundle before installing this plugin.

composer require setono/sylius-analytics-plugin

Step 2: Enable the plugin

Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project before (!) SyliusGridBundle:

<?php
$bundles = [
    Setono\SyliusAnalyticsPlugin\SetonoSyliusAnalyticsPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
];

Step 3: Configure plugin

# config/packages/setono_sylius_analytics.yaml
imports:
    # ...
    - { resource: "@SetonoSyliusAnalyticsPlugin/Resources/config/app/config.yaml" }
    # ...

Step 4: Import routing

# config/routes/setono_sylius_analytics.yaml
setono_sylius_analytics:
    resource: "@SetonoSyliusAnalyticsPlugin/Resources/config/routes.yaml"

Step 5: Update your database schema

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

Step 6: Create a property

When you create a property in Google Analytics you receive a measurement id which looks something like G-12345678.

Now create a new property in your Sylius shop by navigating to /admin/google-analytics/properties/new. Remember to enable the property and enable the channels you want to track.

Step 7: You're ready!

The events that are tracked are located in the EventSubscriber folder.

Contribute

Ways you can contribute:

  • Translate messages and validators into your mother tongue
  • Create Behat tests that verifies the scripts are outputted on the respective pages
  • Create new event subscribers that handle Analytics events which are not implemented

Thank you!