PrestaShop
Add Rybbit analytics to your PrestaShop store
PrestaShop's back office has no built-in setting for custom <head> code, so the snippet goes in either through a header-injection module from the Addons marketplace or directly into your theme's head.tpl. Either way, clear the cache afterwards.
Get your tracking snippet
In your Rybbit dashboard, open Site Settings → Tracking Script and copy your snippet. It looks like this:
<script src="https://app.rybbit.io/api/script.js?siteId=YOUR_SITE_ID" defer></script>YOUR_SITE_ID is the numeric ID of your site. If you self-host Rybbit, app.rybbit.io is the domain of your own instance.
Add the snippet to PrestaShop
- In the back office, go to Modules > Module Manager (or Module Catalog) and install a module that injects custom HTML into the page header, for example a "Custom HTML" or "Header code" module from the PrestaShop Addons marketplace.
- Open the module's configuration, paste the snippet into its head / header code field, and save.
- Go to Advanced Parameters > Performance and click Clear cache.
Edit a child theme. Changes to the parent theme are lost on theme updates.
- Over FTP/SFTP or a file manager, open
/themes/your-theme-name/templates/_partials/head.tpl. - Paste the snippet at the end of the file, before the closing
</head>tag, and save. - Go to Advanced Parameters > Performance and click Clear cache.
Verify installation
Open your live site in a new tab and click through a few pages. Within a few seconds the pageviews appear in the Rybbit dashboard.
If nothing shows up:
- View the page source and search for
script.js?siteId=to confirm the snippet is on the page. - Open the browser Network tab and check that
script.jsreturns200and thatPOSTrequests go to/api/track. - Disable ad blockers, or set up a proxy so the script loads from your own domain.
- See the script troubleshooting guide for other common causes.
Track custom events
Purchase
Add this to your theme's order-confirmation.tpl, or output it from a module hooked to the order confirmation page. PrestaShop renders templates with Smarty, so the $order variables are filled in with the order data:
{if isset($order)}
<script>
(function () {
function waitForRybbit(callback, timeout) {
var start = Date.now();
(function check() {
if (window.rybbit && typeof window.rybbit.event === 'function') {
callback();
} else if (Date.now() - start < timeout) {
setTimeout(check, 100);
}
})();
}
waitForRybbit(function () {
window.rybbit.event('purchase', {
transaction_id: '{$order.details.reference}',
value: {$order.totals.total.amount},
currency: '{$order.totals.total.currency}'
});
}, 5000);
})();
</script>
{/if}waitForRybbit polls until the tracking script from head.tpl has defined window.rybbit, so the event is not lost when the confirmation script runs first.
Troubleshooting
- Script not on the page: clear the cache under Advanced Parameters > Performance, and temporarily disable any JavaScript optimisation or combine/minify module.
- Theme updates overwrite the snippet: keep template edits in a child theme; parent-theme changes are lost on update.
- Purchase event missing: the
$orderSmarty variables differ between PrestaShop versions. Compare them with your version'sorder-confirmation.tpland place a test order to confirm the event arrives.
Next steps
- Track custom events such as signups, purchases and button clicks.
- Identify users to connect sessions to accounts.
- Proxy the script through your own domain to bypass ad blockers.
- Script attributes let you skip or mask URLs and tag events.