Whenever the pixel loads, you can include User properties (data about the User) and it will appear in your Facebook Analytics dashboard under People > User Properties. You can then use these properties to further define your website visitors so you can analyze their activities and evaluate the effectiveness of your conversion funnels.
To include user properties:
To set a User ID, call the pixel's fbq('init')
function with your pixel's ID and a JSON object containing a uid
property as additional parameters:
fbq('init', '<pixel-id>', {uid: '<user-id>'});
Placeholder | Description |
---|---|
| Your pixel's ID. |
| A unique combination of letters and numbers that identifies the User. Maximum length 99 characters. Do not use any personally identifying information, such as names or email addresses. |
For example:
fbq('init', '283859598862258', {uid: 'abc123'});
To set User properties, call the pixel's fbq('setUserProperties')
function with your pixel's ID and a JSON object containing your properties as additional parameters:
fbq('setUserProperties', '<pixel-id>',
{
<user-property>: '<property-value>',
...
}
);
Placeholder | Description |
---|---|
| Your pixel's ID. |
| A predefined property name, or custom property name. Predefined property names must start with a dollar sign ( |
| A string less than 100 characters. If the property already exists for the set User ID, the new property value will overwrite the existing value. |
For example:
fbq('setUserProperties', '283859598862258', { $state: 'California', $city: 'Menlo Park', shoeSize: '11', shoeWidth: 'D', subscription: 'premium' } );
The pixel supports the following predefined User properties. All predefined User properties must begin with a dollar sign ($
):
Property Name | Description |
---|---|
| The UNIX timestamp when the user account was created. |
| The city in which the user lives. |
| The country in which the user lives. |
| The preferred currency of the user. |
| The gender of the user. To get consistent analytics, set this to m or f. |
| The source from which the user installed your app. |
| The preferred language of the user. |
| The state in which the user lives. |
| The type of the user. You define the types to get the analytics results you want. |
| The zip code of the user. |
The following example shows how to set the User ID abc123
for a pixel with the ID 283859598862258
with a mix of predefined and custom User parameters:
// Set the User ID fbq('init', '283859598862258', {uid: 'abc123'}); // Set the User Properties fbq('setUserProperties', '283859598862258', { $state: 'California', $city: 'Menlo Park', shoeSize: '11', shoeWidth: 'D', subscription: 'premium' } );