Download the PHP package anthonypauwels/datalayer without Composer

On this page you can find all versions of the php package anthonypauwels/datalayer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package datalayer

PHP DataLayer

A helper package that help to generate Google's DataLayer script on pages.

Installation

Require this package with composer.

Laravel without auto-discovery:

If you do not use auto-discovery, add the ServiceProvider to the providers array in config/app.php :

Then add this line to your facades in config/app.php :

Finally, add your GTM-ID in config/datalayer.php.

Usage

Without Laravel

You must create a SessionHandler object. Handler uses session to pass data through pages. Then you can pass the SessionHandler to the DataLayerHandler using the constructor :

With Laravel

The package provides by default a Facade for Laravel application. You can call methods directly using the Facade or use the alias instead.

API documentation

Examples bellow are using Laravel Facade DataLayer.

In your controllers

Push one value in the DataLayer

Push an array of data in the DataLayer

Do not hesitate to check the prototype of the method to view all possibles options.

In your views

Publish the DataLayer in the view

Just call this method in your app layout before the closing tag.

It will print this entire HTML code in your layout :

Do not forget to call DataLayer::noScript() right after your tag :

It will print the following :

You can use an optional array to choose if you do not want to initialise the global JS object, initialise the Google Tag Manager script or to clear data after publish.

It will just print this :

Blade directives

If you use DataLayerHandler with Laravel, you can use custom Blade directives to insert codes into the view without using the facade directly :

The DataLayer is cleared after each call to the DataLayer::publish() method except if the option clear is set to false.

Push an array of data in the DataLayer

Others methods

Load the data from session

Save the data in the session

Clear the data in the session

Get the array data

Print the global JS object in the view

It will print this in the HTML :

Print the Google Tag Manager script in the view

The $gtm_id parameter is optional. If omitted, it will use the Google ID set in your .env file.

Also, do not forget to add the

Show the content of the DataLayer (debug purpose)

Requirement

PHP 8.0 or above

See also


All versions of datalayer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package anthonypauwels/datalayer contains the following files

Loading the files please wait ....