Kategorien
SSGTM

SSGTM for Prestashop

On this page I explain everything you need to know about this module. Let’s start with the three areas of the module:

In the first area you make module settings.
The second area contains a list of all code templates.
In the third area you can edit an existing code template or create a new one.

  1. In the first area you make module settings.
  2. The second area contains a list of all code templates.
  3. In the third area you can edit an existing code template or create a new one.

Settings

  1. You can activate & deactivate the module at any time. If the module is deactivated, no scripts will be loaded into your site. Only when it is activated, the module loads the Google Tag Manager in your page and inserts the code templates.
  2. Most Prestashop themes use jQuery. This is a very common JavaScript library that simplifies access to the JavaScript objects on your page. If your theme does not use jQuery, the SSGTM module can load it for you. You should not enable this option if jQuery is already loaded. Otherwise it will cause conflicts and errors.
  3. The GTM-ID can be found in the workspace of the Google Tag Manager

ToDo: Activate the module, copy the GTM-XXXX-ID and save the settings

Code-Templates

Standard code templates are loaded with the installation of the module. The are called „snippets„.

Depending on whether you have Prestashop 1.6 or 1.7, snippets are installed that work for the default Prestashop theme.

Important: If you are using a theme other than Prestashop’s default theme, or have made changes to the default theme, not all snippets may work and need to be customized.

  1. The table shows all code templates (snippets) that have been created. A snippet has an internal name, it is only valid for a certain page and it consists of a JavaScript code.
  2. You can add more snippets if needed. You can do this with the „+“ sign in the upper right corner.
  3. When you click on a snippet or select „View“ from the menu, the module opens the snippet for editing. You can also delete it using the same menu.

Edit snippet

When you open a snippet for editing, you have three fields at the bottom of the editor.

  1. The name can be chosen freely and only for internal use. Name the snippet as descriptive as possible so that you can see at first glance what kind of code it is.
  2. On which pages should this snippet be loaded into the page? The snippet page is the internal name of the Prestashop controller. index is the start page, for example. category is the category page. order is the checkout and order process. etc. You can specify multiple pages by listing them with a „,“ (comma).
How the pages are called can be found in the „Page“ column under „Traffic & SEO“.
  1. The „Snippet Code“ is the JavaScript code to be loaded on the pages. Here you can make practically all the adjustments you need to make the Google Tag Manager work in your shop.

How to test

You can test if your snippet is loaded into the page directly on your page by viewing the page source code. Either scroll to the bottom or search for „gtmData“.

Just before the closing </body> tag you should find the two variables dataLayer and gtmData and your snippet.

The gtmData object for developers.

Before each code-snippet, the SSGTM module inserts a gtmData object, which may look something like this (depending on the page).

window.gtmData = {
	"page":"cart",
	"language":{"id":2,"code":"en"},
	"shop":{"id":1,"name":"Your Shop"},
	"currency":{"id":1,"code":"EUR"},
	"products":[{
		"id":"44",
		"name":"Your Product",
		"price":24.950001,
		"quantity":1,
		"brand":"Product Brand"}
	]
};

You can use this object in your code snippets and depend on it. This is also the way all of my code-snippets work, which the module loads during installation.

For questions you can contact me directly via the Prestashop Addons page.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.