How it works?
Piano Analytics employs a structured data model centered around events and properties to facilitate precise and scalable tracking across various digital platforms.
Core Concepts
- Events represent user interactions or system occurrences that you intend to monitor, such as page views, clicks, or transactions.
- Properties provide contextual information about each event, encompassing details like page title, categorie, genre, publication date and so forth.
This event-property schema enables the construction of a comprehensive and adaptable data model, allowing for in-depth analysis of user behavior
Standard and Custom properties
Piano Analytics offers an extensive library of over 70 predefined events and 450 standard properties, readily available for immediate deployment. These standard definitions cover a wide range of common analytics scenarios
Feel free to consult the documentation on standard events.
For specific business requirements, you can define custom events and properties to capture unique interactions and contextual data pertinent to your objectives.
Calculated and Processed properties
Properties in Piano Analytics are categorized based on their processing methodology:
- Processed Properties: These are directly included in the tracking payload and are immediately available for analysis upon data collection.
- Calculated Properties: These are derived during the data processing phase and are not included in the initial tracking payload.
The data model specifies the treatment type for each property, guiding you on their appropriate usage in event tracking.
Let's start together
You want to start your implementation by collecting your first audience measurement data.
To do so, we will use the events and properties provided by default by Piano Analytics data model.
Lightweight tagging
This feature is only available with JS SDK >= 6.16.0
To start collecting data, you can activate the Instant Tracking. This modules involves adding a single script tag to your website, which initializes the Piano Analytics tracking script with default settings and start tracking the basic interactions.
Here is an example of how to initialize Piano Analytics with default settings and start tracking right now:
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>My Page</title>
<script>
(function (_config) {
var script = document.createElement("script");
script.src = "https://tag.aticdn.net/piano-analytics.js";
script.async = true;
script.crossorigin = "anonymous";
script.dataset.config = JSON.stringify(_config);
document.head.appendChild(script);
})({
site: 123456789,
collectDomain: "https://xxxxxxx.pa-cd.com",
instantTracking: true,
});
</script>
</head>
<body>
...
</body>
</html>
Measure a page display
We will simply fill in the name of the event we want to measure, and link the properties that allow us to understand this interaction:
- Javascript
- Android (3.3.0+)
- Android
- Apple
- HTTP
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>My Page</title>
<script>
(function (_config) {
var script = document.createElement("script");
script.src = "https://tag.aticdn.net/piano-analytics.js";
script.async = true;
script.crossorigin = "anonymous";
script.dataset.config = JSON.stringify(_config);
document.head.appendChild(script);
})({
site: 123456789,
collectDomain: "https://xxxxxxx.pa-cd.com",
});
</script>
</head>
<body>
...
<script type="text/javascript">
pa.sendEvent(
"page.display", // Event name
{
page: "page name", // Event properties
page_chapter1: "level 1",
page_chapter2: "level 2",
page_chapter3: "level 3",
}
);
</script>
</body>
</html>
Before 6.16.0
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>My Page</title>
<script
type="text/javascript"
crossorigin="anonymous"
src="https://tag.aticdn.net/piano-analytics.js"
></script>
<script type="text/javascript">
pa.setConfigurations({
// Basic configuration to send events
site: 123456789,
collectDomain: "https://<xxxxxxx>.pa-cd.com",
});
</script>
</head>
<body>
...
<script type="text/javascript">
pa.sendEvent(
"page.display", // Event name
{
page: "page name", // Event properties
page_chapter1: "level 1",
page_chapter2: "level 2",
page_chapter3: "level 3",
}
);
</script>
</body>
</html>
pa.setConfiguration(new Configuration.Builder()
.withCollectDomain("<xxxxxxx>.pa-cd.com")
.withSite(123456789)
.build()
);
...
pa.sendEvent(new Event("page.display", new HashMap<String, Object>() {{ // Event name
put("page", "page name"); // Event properties
put("page_chapter1", "level 1");
put("page_chapter2", "level 2");
put("page_chapter3", "level 3");
}}));
import io.piano.android.analytics.Configuration
import io.piano.android.analytics.PianoAnalytics
...
val configuration = Configuration.Builder(
collectDomain = "<xxxxxxx>.pa-cd.com",
site = 123456789
).build()
PianoAnalytics.init(applicationContext, configuration)
...
PianoAnalytics.getInstance().sendEvents(
Event.Builder("page.display")
.properties(
Property(PropertyName("page"), "page name"),
Property(PropertyName("page_chapter1"), "level 1"),
Property(PropertyName("page_chapter2"), "level 2"),
Property(PropertyName("page_chapter3"), "level 3"),
)
.build()
)
pa.setConfiguration(ConfigurationBuilder()
.withCollectDomain("<xxxxxxx>.pa-cd.com")
.withSite(123456789)
.build()
)
...
pa.sendEvent(Event("page.display", data: [ // Event name
"page": "page name", // Event properties
"page_chapter1": "level 1",
"page_chapter2": "level 2",
"page_chapter3": "level 3"
]))
const site_id = `123456789`;
const visitor_id = `<visitor_id>`;
const endpoint = `<xxxxxxx>.pa-cd.com`;
fetch(`https://${endpoint}/?s=${site_id}&idclient=${visitor_id}`, {
method: "POST",
body: JSON.stringify({
events: [
{
name: "page.display",
data: {
page: "page name",
page_chapter1: "level 1",
page_chapter2: "level 2",
page_chapter3: "level 3",
},
},
],
}),
});
pa.setConfigurations()
initializes the SDK with your site's unique identifier and collection domain.
pa.sendEvent()
dispatches a page.display
event, accompanied by hierarchical page information through properties.
Please refer to Javascript configuration.
So here we have linked an event and four properties:
Event | Properties |
---|---|
page.display | page page_chapter1 page_chapter2 page_chapter3 |
If you want information about how to deploy the library, please read the dedicated article.
Measure a click
We are now going to measure a click on the page on which we have just placed our first tag.
This click will contain context, i.e. information related to the environment in which it was made. We are going to trace the page, and the chapters of the page, on which the click took place:
- Javascript
- Android (3.3.0+)
- Android
- Apple
- HTTP
<html>
<head lang="en">
<meta charset="UTF-8" />
<title>My Page</title>
<script>
(function (_config) {
var script = document.createElement("script");
script.src = "https://tag.aticdn.net/piano-analytics.js";
script.async = true;
script.crossorigin = "anonymous";
script.dataset.config = JSON.stringify(_config);
document.head.appendChild(script);
})({
site: 123456789,
collectDomain: "https://xxxxxxx.pa-cd.com",
});
</script>
</head>
<body>
<button>My button</button>
<script type="text/javascript">
const button = document.querySelector("button");
button.addEventListener("click", (event) => {
pa.sendEvent(
"click.navigation", // Event name
{
click: "click name", // Event properties
click_chapter1: "click level 1",
click_chapter2: "click level 2",
click_chapter3: "click level 3",
page: "page name",
}
);
});
</script>
</body>
</html>
pa.sendEvent(new Event("click.navigation", new HashMap<String, Object>() {{ // Event name
put("click", "click name"); // Event properties
put("click_chapter1", "click level 1");
put("click_chapter2", "click level 2");
put("click_chapter3", "click level 3");
put("page", "page name");
}}));
PianoAnalytics.getInstance().sendEvents(
Event.Builder("click.navigation")
.properties(
Property(PropertyName("click"), "click name"),
Property(PropertyName("click_chapter1"), "click level 1"),
Property(PropertyName("click_chapter2"), "click level 2"),
Property(PropertyName("click_chapter3"), "click level 3"),
Property(PropertyName("page"), "page name"),
)
.build()
)
pa.sendEvent(Event("click.navigation", data: [ // Event name
"click": "click name", // Event properties
"click_chapter1": "click level 1",
"click_chapter2": "click level 2",
"click_chapter3": "click level 3",
"page": "page name"
]))
const site_id = `123456789`;
const visitor_id = `<visitor_id>`;
const endpoint = `<xxxxxxx>.pa-cd.com`;
fetch(`https://${endpoint}/?s=${site_id}&idclient=${visitor_id}`, {
method: "POST",
body: JSON.stringify({
events: [
{
name: "click.navigation",
data: {
click: "click name", // Event properties
click_chapter1: "click level 1",
click_chapter2: "click level 2",
click_chapter3: "click level 3",
page: "page name",
},
},
],
}),
});
So here we have linked an event and five properties:
Event | Properties |
---|---|
click.navigation | click click_chapter1 click_chapter2 click_chapter3 page |
Feel free to add custom properties to the event, in addition to the standard properties offered by default!