Using npm:
$ npm install --save @webtrekk-smart-pixel/react$ npm install --save @webtrekk-smart-pixel/nextWebtrekkAutoTracking
If you want to use automatic page tracking, add WebtrekkAutoTracking to your root App and configure the options.
Note
With Next.js, automatic page tracking on route changes works with the pages router.
WebtrekkAutoTrackinglistens to the router events ofnext/router, which you pass with therouteroption. The app router (next/navigation) has no router events, soWebtrekkAutoTrackingdoes not track route changes there. With the app router, send a page request yourself on each route change, for example withtrackPage()in a client component.
Value | Description | Data type | Required | Default value |
|---|---|---|---|---|
trackId | Enter your Track ID here. It is under Mapp Q3 >Configuration > System Configuration > Data Collection. If the request should be sent to several accounts, you can add multiple Track IDs separated by a comma. |
| Yes | |
trackDomain | Enter the domain to which the data should be sent. If you are using a Mapp Intelligence track domain, you will find it in the setup information sent to you via email. |
| Yes | |
activateAutoTracking | Defaults to |
| - |
|
activateActions | Activates the automatic event tracking. |
| - |
|
activateTeaser | Activates the teaser tracking extension. |
| - |
|
activateProductList | Activates the product list extension. |
| - |
|
activateContentEngagement | Activates the content engagement extension. |
| - |
|
import { WebtrekkAutoTracking } from "@webtrekk-smart-pixel/react";
render()
{
return (
<div>
<Switch>
<Route exact path="/" component={ Home } />
<Route path="*" component={ NotFound } />
</Switch>
<WebtrekkAutoTracking
trackId="111111111111111"
trackDomain="analytics01.wt-eu02.net"
activateAutoTracking={ true }
activateActions={ true }
activateTeaser={ true }
activateProductList={ true }
activateContentEngagement={ true }
/>
</div>
);
}import React from "react";
import App from "next/app";
import Router from "next/router";
import { WebtrekkAutoTracking } from "@webtrekk-smart-pixel/next";
class MyApp extends App {
render() {
const {Component, pageProps} = this.props;
return (
<div>
<Component { ...pageProps } />
<WebtrekkAutoTracking
trackId="111111111111111"
trackDomain="analytics01.wt-eu02.net"
router={Router}
activateAutoTracking={ true }
activateActions={ true }
activateTeaser={ true }
activateProductList={ true }
activateContentEngagement={ true }
/>
</div>
);
}
}
export default MyApp;