Meta (Facebook) feed field internal_label format

Among the data feed fields, Meta has recommended an internal_label field which could be use to filter items in set.

Its value could be tricky to get right, as the requested value is different between CSV/TSV and XML feed formats.

CSV/TSV format

The value is taking a JSON representation of a list of texts. The documentation is very limited and does not specify the JSON format in details, e.g. how to "escape" the texts when they contain special character like the quotes or commas.

Enclose each label in single quotes (') and separate multiple labels with commas (,). Don’t include white space at the beginning or end of a label. Character limit: 5,000 labels per product and 110 characters per label.

Example: ['summer','trending']

In Multifeeds, we could attempt to build the value is an expression with map and join functions

"[" + join(map(Collection handle list ,"\"'\"+self+\"'\""),",") + "]"

How it looks in the app

This works, but only because Collection handle list never contains special characters that need to be "escaped". The expression is also not difficult to read and maintain.

Multifeeds has a special function, stringify, which could be use for the field. The function take an object and return its JSON5 representation. If a list is provided, the result is properly formatted for the internal_label which can be read by Meta. Because special characters (quotes, etc.) are "escaped", it is safe to use other list tokens.

The expression is also much more readable

stringify(Collection title list )

Of course, another sensible value for internal_label would be Tag list

stringify(Tag list)

Now you can skip the stringify function in the internal_label expression

Updated: Thanks to this simplification, you can skip entering stringify function in CSV feed. Please note that it only applies to "internal_label" field. A different field name would yield different value

Different value of the seemingly same expressions

XML format

Although not documented in Meta documentation, we have learnt that for XML feed internal_label needs to be submitted in repeated <internal_label> tags

<item>
...
<internal_label>
egnition-sample-data
</internal_label>
<internal_label>
men
</internal_label>
<internal_label>
summer
</internal_label>
<internal_label>
vans
</internal_label>
...
</item>

For this to be possible, simply remove the use of stringify function, as the app automagically create repeated XML tags for list value

The expression for XML feed
XML feed output

Simplification

In Multifeeds we strive to simplify things, so you can use the same list-returning expression for internal_label.

You now can use a list-returning expression for internal_label in both CSV and XML feeds

What really happens is that if the field name is "internal_label", the app silently apply the stringify function in the background if necessary. Using the same expression for all feed types also mean you could switch between the formats more easily.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us