Getting started
Requirements
- Craft CMS 3.0.20, 4.0.0, 5.0.0 or later
- Access to Facebook Events Manager (See Facebook Business)
Install Plugin
The plugin can be installed via the Plugin Store in the Craft Control Panel.
Or, open your terminal, go the Craft project and install the plugin via Composer:
composer require dwy/facebook-conversion
./craft plugin/install facebook-conversion
Setup the Pixel ID
If your website doesn't have a Facebook Pixel yet, start by creating one:
- Go to Events Manager.
- Click Connect Data Sources and select Web.
- Select Facebook Pixel and click Connect.
- Add your Pixel Name.
- Enter your website URL to check for easy setup options.
- Click Continue.
Configuration
As soon as the Plugin is installed you can start configuring via the settings page.
The Facebook Pixel ID can be copied in the Data Source screen.
The Access Token can get generated in the Settings tab.
When sending server events to Facebook they won't show in real-time, which doesn't help to validate and debug the integration. Luckily there is a way to debug more easily, when adding a Test Event Code the events will load in real-time in the Test Events tab.
WARNING
Only fill in the Test Event Code when you're validating or debugging the integration.
Template
If you Facebook Pixel is not added directly in the Template, or not added by another Plugin (E.g. SEOmatic), you can add it through the Facebook Conversion Plugin. In order to do so, add the following Twig hooks to the head and body of your page in your template:
{% hook 'facebook-conversion-head-tag' %}
{% hook 'facebook-conversion-body-tag' %}
E.g.:
<head>
<meta charset="utf-8">
<title>My Website</title>
{% hook 'facebook-conversion-head-tag' %}
</head>
<body>
{% hook 'facebook-conversion-body-tag' %}
Legal
Please follow the government regulations that apply to your business. Be aware that for EU countries the "Cookie Law" also applies to Server Events and other technologies. Make sure to update your Privacy Policy and ask for consent before sending any data to partners such as Facebook.
The use of the Plugin, its functionality, and the legal implementation is the responsibility of the owner of the website.