w3cdatalayer

package
v0.0.0-...-bb92df6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2021 License: OSL-3.0 Imports: 4 Imported by: 0

README

W3C Datalayer Module

Module that makes it easy to add common datalayer to your website - which makes it easier to connect to analytics and to implement tracking pixels and tag managers.

The datastructure is oriented at: www.w3.org/community/custexpdata/

The datalayer information provides an easy access to common information relevant for tracking and datalayer. The datalayer module therefore listens to various events and adds information to the datalayer

Configurations:

w3cDatalayer:
  pageInstanceIDPrefix: "mywebsite"
  pageInstanceIDStage: "%%ENV:STAGE%%production"
  pageNamePrefix: My Shop
  siteName:  My Shop
  defaultCurrency: GBP
  version: 1.0
  # If you want sha512 hashes instead real user values
  hashUserValues: true

Also it reuses the configuration from locale package to extract the language:

locale:
  locale: en-gb

Usage example:

Template function w3cDatalayerService

The template function provides access to the current requests datalayer. You can get the datalayer and you can modify it:

For some values in the datalayer the template knows better than the backend what to put in, so please call the appropriate setter like this:

  - var result = w3cDatalayerService().setPageCategories("masterdata","brand","detail")
  - var result = w3cDatalayerService().setBreadCrumb("Home/Checkout/Step1")
  - var result = w3cDatalayerService().setPageInfos("pageID","pageName")
  - var result = w3cDatalayerService().setCartData(decoratedCart)
  - var result = w3cDatalayerService().setTransaction(cartTotals, decoratedItems, orderid)
  - var result = w3cDatalayerService().addProduct(product)
  - var result = w3cDatalayerService().addEvent("eventName")
      

If you want to populate the w3c datalayer to your page you can render the final digitalData object like this:

- var w3cDatalayerData = w3cDatalayerService().get()
script(type="text/javascript").
  var digitalData = !{w3cDatalayerData}
  digitalData.page.pageInfo.referringUrl = document.referrer
  digitalData.siteInfo.domain = document.location.hostname

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct{}

Module represents our w3cdatalayer module

func (*Module) Configure

func (m *Module) Configure(injector *dingo.Injector)

Configure the product URL

func (*Module) CueConfig

func (m *Module) CueConfig() string

CueConfig schema and configuration

func (*Module) FlamingoLegacyConfigAlias

func (m *Module) FlamingoLegacyConfigAlias() map[string]string

FlamingoLegacyConfigAlias mapping

Directories

Path Synopsis
interfaces

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL