Partager via


targetingCriteria Examples

This page starts with the most basic structure of targetingCriteria object and goes on the explain how more complex criteria can be developed using boolean AND / OR constructs provided.

The basic structure for any targetingCriteria is as follows

    "targetingCriteria":{
        "include":{

        },
        "exclude":{

        }
    }

Now, let’s see the object with only “include” part. The “include” object contains a single encompassing array object called “and”. Each element within this “and”, contains at least 1 or many “or” objects. This example just contains a single “or” object:

This object is “including” all users with seniority:5 which is “Manager” OR seniority:6 which is “Director”

    "targetingCriteria":{
        "include":{
            "and":[
                {
                    "or":{
                        "urn:li:adTargetingFacet:seniorities":[
                            "urn:li:seniority:5",
                            "urn:li:seniority:6"
                        ]
                    }
                }
            ]
        },
        "exclude":{

        }
    }

Each “or” object can contain collection of adTargetingFacets. Each “adTargetingFacet” supports a list of pre-defined, standardized values. Within a single adTargetingFacet, all values in the list are OR’d. Here is an example with two different types of adTargetingFacets within the “or” object:

This object is “including” users who either are “Managers” OR have “MBA” degree

    "targetingCriteria":{
        "include":{
            "and":[
                {
                    "or":{
                        "urn:li:adTargetingFacet:seniorities ":[
                            "urn:li:seniority:5"
                        ],
                        "urn:li:adTargetingFacet:degrees":[
                            "urn:li:degree:700"
                        ]
                    }
                }
            ]
        },
        "exclude":{

        }
    }

Next, is an example of multiple elements within the “and” array object:

This object is “including” users who (are “Managers” OR have “MBA” degree) AND the users work at a company belonging to the “Semiconductors” industry

    "targetingCriteria":{
        "include":{
            "and":[
                {
                    "or":{
                        "urn:li:adTargetingFacet:seniorities":[
                            "urn:li:seniority:5"
                        ],
                        "urn:li:adTargetingFacet:degrees":[
                            "urn:li:degree:700"
                        ]
                    }
                },
                {
                    "or":{
                        "urn:li:adTargetingFacet:industries":[
                            "urn:li:industry:7"
                        ]
                    }
                }
            ]
        },
        "exclude":{

        }
    }

The schema for “exclude” object is slightly different from the “include” object. All facets values mentioned in the “exclude” list are filtered out of the results. The “exclude” values in the list are OR’d.

This object “includes” all users in California , “excluding” users who are “Managers”

    "targetingCriteria":{
        "include": {
            "and": [{
                "or": {
                    "urn:li:adTargetingFacet:locations": [
                        "urn:li:geo:102095887"
                    ]
                }
            }]
        },
        "exclude": {
            "or": {
                "urn:li:adTargetingFacet:seniorities": [
                    "urn:li:seniority:5"
                ]
            }
        }
    }

The last example is one which uses both “Include” and “Exclude” objects in the criteria:

This object is “including” users who either (are “Managers” OR have “MBA” degree) AND the users who are native to “United States” and “excluding” users working for companies belonging to the “Semiconductors” industry and users working in “California”

    "targetingCriteria":{
        "include":{
            "and":[
                {
                    "or":{
                        "urn:li:adTargetingFacet:seniorities":[
                            "urn:li:seniority:5"
                        ],
                        "urn:li:adTargetingFacet:degrees":[
                            "urn:li:degree:700"
                        ]
                    }
                },
                {
                    "or":{
                        "urn:li:adTargetingFacet:locations":[
                            "urn:li:geo:103644278"
                        ]
                    }
                }
            ]
        },
        "exclude":{
            "or":{
                "urn:li:adTargetingFacet:industries":[
                    "urn:li:industry:8"
                ],
                "urn:li:adTargetingFacet:locations":[
                    "urn:li:geo:102095887"
                ]
            }
        }
    }

Note

“exclude” contains a single OR construct under which all exceptions can be listed. This implies that, in order to filter out a user from the all the users shortlisted by “include” clause,  the user must match at least one of the exceptions defined in "exclude" clause.