Connect with us

FACEBOOK

Simplifying analytics for Messenger bots

Published

on

For the busy developers or lazy readers: We have a new toy for you. Go and have fun! 🤝

It’s conventional wisdom that you can’t improve something that you can’t measure. Product usage data is not only interesting and nice to have, but an important foundation for making the right product decisions and assessing the effectiveness and ROI of your Messenger bot compared to other channels.

Example bot funnel for an e-commerce flow

For traditional websites, there is a myriad of tools and services available that web developers can use. This article outlines the best practice for using Facebook Analytics for Messenger bots and introduces an npm package which is aimed at helping developers to make integration effortless.

Experienced bot developers know that launching a conversational experience is only the start of the journey to improving your service over time — based on real user interactions. It’s a tough, but rewarding challenge because conversations are not deterministic by nature like graphical user interfaces. In other words, the bandwidth of user actions is much wider than on traditional websites where the user can scroll, click pre-defined buttons, and write text in known input fields or text areas.

On the Messenger platform, the most integrated way to log bot activity is to use Facebook Analytics (FBA) in form of custom app events through the app activities endpoint. Although logging an event to FBA only requires a simple API call, many bot developers skip this step and launch Messenger experiences without having a measurement framework in place.

The Partner Engineering team at Facebook has therefore set out to simplify event logging for Messenger bots. The result is a thin integration layer that sits between your Messenger bot and Facebook Analytics.

Meet the messenger-analytics package

The messenger-analytics package offers a simple interface to Facebook Analytics (FBA) for Messenger bots. It provides a thin integration layer as well as a collection of commonly used bot events to give you a basic idea of useful metrics.

Facebook Analytics (FBA) is a people-first analytics tool for an omni-channel world. It can be used as a standalone logging solution for your Messenger bot or in addition to other analytics software. FBA is closely integrated with the Facebook ecosystem, including Ads Manager and the Facebook Pixel. This allows you to optimize your campaigns for specific actions in the bot and to combine pixel data from your website with Messenger bot activity.

A question that Facebook Analytics can answer: “How many people purchased an item on my website after having been consulted by the bot beforehand?”

The Facebook Messenger platform automatically logs certain events for your bot, for example “message sent” and “message received”. These events are logged on the app-level and can be visualized in Facebook Analytics (FBA).

In addition to these automatic events, FBA also supports the logging of custom events which enable you to visualize user journeys and track the performance metrics of your choice. The messenger-analytics package helps you to log custom events in Facebook Analytics.

Installation

npm install --save messenger-analytics

Import

const FBA = require("messenger-analytics");

Creating an event logger

Create a logger using the app and page ID associated with your bot.

const logger = new FBA.Logger({
appID: YOUR_APP_ID,
pageID: YOUR_PAGE_ID,
});

Logging events

The simplest form of logging an event is to provide an event name and the user identifier (PSID). You can either use an event name defined in this module or choose an arbitrary name.

Note: Whenever possible and applicable, use the so called predefined app events in FBA.EventNames.Predefined. They are utilized across the Facebook ecosystem and are needed for campaign attribution and optimization in Ads Manager. Given the significance of these events for other Facebook products and services, it is advisable to treat them as first choice.

// Using a predefined event name (required if you want to report on a specific metric in Ads Manager)
logger.logEvent(
FBA.EventNames.Predefined.Purchased,
"USER_PSID",
).then(() => {
console.log("Event successfully logged to FBA.");
}).catch((err) => {
console.error(err);
});// Using a custom event name
logger.logEvent(
"subscribed_sports_news",
"USER_PSID",
).then(() => {
console.log("Event successfully logged to FBA.");
}).catch((err) => {
console.error(err);
});

You may also attach parameters to an event. These parameters can be used for filtering, segmentation, and campaign reporting. Predefined events have specific parameter definitions which need to be followed if you want to log purchases and see the purchase value and currency in Ads Manager, as an example. The parameter definitions can be found in the App Events API event structure.

On top of these standard parameters, you may also log additional custom parameters. Parameters for custom events don’t have to follow any naming convention.

// Purchase event with 3 standard 1 custom parameters
logger.logEvent(
FBA.EventNames.Predefined.Purchased,
"USER_PSID",
{
_valueToSum: 87.90, // standard parameter, defaults to 1
fb_num_items: 3, // standard parameter
fb_currency: "EUR", // standard parameter
custom_var: "hello_world", // custom parameter
}
).then(() => {
console.log("Event successfully logged to FBA.");
}).catch((err) => {
console.error(err);
});

These parameters can then be used in FBA to filter your results:

Filtering events by parameters

Platform and language availability

We chose to publish this analytics package for bots built on NodeJS (written in JavaScript) first. Depending on popularity and demand, we might follow up with implementations for other popular “bot builder languages” like PHP, C#, Ruby, or Python. If you have a preference, let us know in the comments! 🙂 In the meantime, you can simply send your requests straight to FBA using our the analytics quick start guide.

Facebook Analytics for Messenger is MIT licensed.

Messenger Developer Blog

FACEBOOK

Helping Prevent Discrimination in Ads that Offer Housing, Employment or Credit Opportunities.

Published

on

iscrimination has no place on Facebook, and our advertising policies have long prohibited unlawful discrimination. Over the last year, our auditors have released two progress updates on Facebook’s Civil Rights Audit and we reached a historic settlement with leading civil rights organizations. As part of the settlement, we introduced a new process for how advertisers based in the US, or trying to reach audiences in the US, can buy ads that offer housing, employment or credit opportunities. These ads are known as Special Ad Categories and are restricted from using the following targeting criteria: age, gender, ZIP code, multicultural affinity or any detailed options describing or appearing to relate to protected characteristics.The Latest News from Facebook for Business

Continue Reading

FACEBOOK

Facebook Brings WhatsApp Integration to Its Revamped Crisis Response Tool

Published

on

Social network giant Facebook is adding a WhatsApp button to crisis response tool, its disaster-reporting and communications feature where a user requests or offers help during a time of emergency. The tool is being used in 300 crises in more than 80 countries presently.

The new feature will allow people in affected areas to provide real-time information related to any disaster, TechCrunch.com reported on Tuesday.

Formerly, replies to requests on Facebook’s crisis response pages could only be sent with Facebook Messenger.

The update allow the social network to provide this information to state and local officials, as well as federal relief agencies such as Direct Relief and the National Alliance for Public Safety GIS Foundation.

Facebook is also expanding its Data for Good tools, using its data to provide relief organisations with information on where to distribute supplies, based on aggregated, anonymised data.

Additionally, Facebook is also updating its disaster maps to be more accurate in collaboration with agencies such as the International Displacement Monitoring Centre.

The new features will allow for photo and video sharing within the Crisis Response centre on Facebook.

Crisis Response originally developed out of a handful of features that help family, friends and communities support one another in the wake of a disaster.

NDTV Gadgets360.com

Continue Reading

FACEBOOK

Facebook to Allow Transfer of Photos, Videos to Google, Other Rivals

Published

on

Facebook started testing a tool on Monday that lets users move their images more easily to other online services, as it faces pressure from regulators to loosen its grip on data. The social network’s new tool will allow people to transfer their photos and videos directly to competing platforms, starting with Google Photos. The company said it will first be available to people in Ireland and will be refined based on user feedback.

The tool will then be rolled out worldwide in the first half of 2020.

US and European regulators have been examining Facebook’s control of personal data such as images as they look into whether the tech giant’s dominance is stifling competition and limiting choice for consumers. Facebook CEO Mark Zuckerberg has reacted by calling for new rules to address “data portability” and other issues.

Facebook said that as it worked on a new set of data portability tools, it had discussions with policymakers, regulators, and academics in the UK, Germany, Brazil, and Singapore to learn about which data should be portable and how to protect privacy.

The company is developing products that “take into account the feedback we’ve received and will help drive data portability policies forward by giving people and experts a tool to assess,” Steve Satterfield, director of privacy and public policy, said in a blog post.

NDTV Gadgets360.com

Continue Reading

Trending