Sending Metadata With Posts

Start sending metadata with your feedback posts.

Robi Rohumaa avatar
Written by Robi Rohumaa
Updated over a week ago

When embedding Featurebase through an IFrame, it is possible to send along metadata.

Metadata could be the following:

  • Device OS

  • App version

  • Any other key-value pair you'd like


What does metadata look like?

The metadata you send along is a JSON object. The allowed values for the keys are: string, date, number, and boolean. You cannot nest objects in the metadata.

Here is an example of some metadata you could send along:

{
"OS": "IOS 16.2",
"App Version": "1.2.3",
"Beta User": false,
"Paid User": true
}

Sending metadata

Let's say you want to send the following metadata along with a users post:

{
"OS": "IOS 16.2",
"App Version": "1.2.3",
"Beta User": false,
"Paid User": true
}

To send this metadata along, we need to send a Javascript postMessage to the Featurebase iframe.

// get the featurebase iframe by its id 
const iframe = document.getElementById('featurebase-frame')

// send a postMessage to the iframe with your desired metadata
iframe.contentWindow.postMessage(
{
data: { type: 'metadata', metadata: { OS: 'IOS 16.2', 'App Version': '1.2.3', 'Beta User': false, 'Paid User': true } },
},
'*'
)

After setting the metadata, the next posts created by the user will have the metadata attached to them.

Did this answer your question?