Prints tracking data used by Google Analytics Enhanced Ecommerce in connection with product links and purchase buttons.

Description

To function properly, the tag requires JavaScript files that can be printed in a theme by using the {SupportScripts} tag.

The tag prints an HTML attribute to which a JSON object with the data read by Enhanced Ecommerce is added.

The tag is used in link elements directing to a product page. Below you can see a usage example for the tag:

<a href="{ProductUrl}" {ProductLinkData}>{ProductName}</a>

If you use product list tags' default outputs in your theme (instead of your own helper files), there is no need for you to add the {ProductLinkData} tag separately.

If your online store uses a custom-made purchase form – implemented without using the {ProductBuy} tag – add the following markup to the purchase form:

<form action="/cart/" enctype="multipart/form-data" method="post" class="BuyForm" {ProductLinkData(type: 'add_to_cart', event: 'submit')}>
    ...
</form>

Syntax

{ProductLinkData(
    event: string,
    type: string
)}

Scope

Required scope: tuote

Attribuutit

event:

Defines an event in connection with which an action is registered in the tracking service.

Allowed values:
  • 'click': Triggers tracking when a link is clicked (default value).
  • 'submit': Triggers tracking when a form is sent.
type:

Defines the action that should be tracked.

Allowed values:

  • 'click_product': Tracks product link clicks (default value).
  • 'add_to_cart': Tracks the actions in which products are added to the shopping cart.

If a product has variations, downloadable files or customizations, the attribute's value is set to 'click_product' automatically.

after/before:

By using the after and before attributes you can define content that is output either after or before the tag's output.

Allowed values:The HTML and Interface markup

E.g.

  • before: '<p>Tämä merkkaus näkyy ennen tagin omaa sisältöä.</p>'
  • after: '<p>Tämä taas näkyy tagin oman sisällön jälkeen.</p>'

If the tag does not produce any content, neither the content of the after and before attributes will be output.

escape:

Adds an escape character before quotation marks in the output.

The attribute makes it easier to process the tag-produced content when using JavaScript.

Allowed values:true/false. The default value is false.

or:

Defines alternative content that is displayed if the tag itself does not produce any content.

Allowed values:The HTML and Interface markup

E.g. or:'Sisältöä ei löytynyt.'