Developer Guide: Performing Grouped Analysis

Many of the available strategies allow you to perform grouped analysis. In this guide you'll learn what grouped analysis is, and what options are available to you.

What is 'grouped analysis'?

Often you'll want to repeat the same analysis for different audiences or topics. For example, if you're looking to find out the content that is being engaged with the most for the topic of 'artificial intelligence' you might want to find this out for multiple industry sectors.

Grouped analysis allows you to request the same analysis for a number of groups in one task. The analysis you request will be repeated for each group independently. The strategy will return a set of results for each group.

The documentation page for a strategy states whether grouped analysis is supported. For example the top_urls strategy does support grouping, as shown by the properties on its documentation page:

If a strategy does not support grouping you can run multiple tasks, one for each of your groups, and combine the results yourself.

Specifying groups

To specify multiple groups for analysis you use the groups parameter.

In this guide we'll briefly cover the available options. For a full explanation of grouping options see the grouping parameters page.

You can specify one of the following parameters under the groups parameter to perform grouped analysis:

  • top - group by the top n values for a demographic dimension.
  • list - group by a set of values for a demographic dimension.
  • custom - group by arbitrary topic and audience definitions.

Grouping by 'top' demographic segments

The top parameter performs grouping by the largest demographic segments in an audience.

For example, if the 5 countries are specified, then the analysis will be performed for the 5 countries with the largest active audiences on LinkedIn.

The following parameters will analyze the top urls for 'artificial intelligence' for each of the top 3 countries:

{
    "type": "strategy",
    "subscription_id": "cd99abbc812f646c77bfd8ddf767a134f0b91e84",
    "name": "Top urls for artificial intelligence",
    "parameters": {
        "strategy": "top_urls",
        "version": 1,
        "parameters": {
            "keywords": {
                "any": ["artificial intelligence", "ai"]
            },
            "comparison_audience": "global",
            "groups": {
                "top": {
                    "countries": 3
                }   
            }
        }
    }
}

The topic specified by the keywords parameter will be applied to the analysis for each of the groups.

Grouping by explicit demographic segments

The list parameter performs grouping by a specific set of demographic segments. You must use valid demographic segments when specifying segments to analyze.

The following parameters will analyze the top urls for 'artificial intelligence' for each of 3 sectors:

{
    "type": "strategy",
    "subscription_id": "cd99abbc812f646c77bfd8ddf767a134f0b91e84",
    "name": "Top urls for artificial intelligence",
    "parameters": {
        "strategy": "top_urls",
        "version": 1,
        "parameters": {
            "keywords": {
                "any": ["artificial intelligence", "ai"]
            },
            "comparison_audience": "global",
            "groups": {
                "list": {
                    "sectors": ["high-tech", "transportation", "finance"]
                }   
            }
        }
    }
}

Again the topic specified by the keywords parameter will be applied to the analysis for each of the groups.

Specifying custom groups

The custom parameter allows you to specify up to 10 custom groups to perform analysis for.

For each group you must specify at least one of the keywords, concepts, or audience parameters. These parameters are the same types as you use elsewhere for strategies.

The following parameters will analyze the top urls for 'artificial intelligence' for 2 custom groups, based upon audience demographics:

{
    "type": "strategy",
    "subscription_id": "cd99abbc812f646c77bfd8ddf767a134f0b91e84",
    "name": "Top urls for artificial intelligence",
    "parameters": {
        "strategy": "top_urls",
        "version": 1,
        "parameters": {
            "keywords": {
                "any": ["artificial intelligence", "ai"]
            },
            "comparison_audience": "global",
            "groups": {
                "custom": {
                    "large co decision makers": {
                        "audience": {
                            "seniorities": ["director", "vp", "cxo", "partner", "owner"],
                            "company_sizes": ["1001-5000", "5001-10000", "10001+"]
                        }
                    },
                    "small companies": {
                        "audience": {
                            "company_sizes": ["myself only", "1-10", "11-50"]
                        }
                    }
                }   
            }
        }
    }
}

The labels you give for the groups (in this example 'large co decision makers' and 'small companies') will be used to label the result sets returned by the strategy.

In the example we've based our groups on demographic segments, but you could use any combination of the keywords, concepts, and audience parameters to build your custom groups.

Top-level parameters

In the examples above we have used the keywords parameter at the top level to apply the same topic for each group.

Parameters at the same level as the group parameter will be applied to all analysis. So for example if you apply an audience parameter, or a sort_by parameter, these will be applied to the analysis for each group.

note icon

This is also the case for comparison audiences. Currently you can only specify one comparison audience which will be used for each group. If you wish to use different comparison audiences for each group you will need to run a separate task for each group and combine the results yourself.

Output format

When you run a grouped analysis the output of the strategy will reflect the groups you specified.

Taking our last example above which uses custom groups, the result structure would be as follows:

{
    "groups": {
        "large co decision makers": {
            "redacted": false,
            "unique_authors": 92000,
            "interactions": 103000,
            "urls": [...]
        },
        "small companies": {
            ...
        },
        ...
    }
}

For each group the redacted property tells you if the analysis was successful, or could not be returned due to the audience being too small to analyze.

If the result is not redacted for the group, the results are included in the same structure as they would be if no grouping had been applied. In this case a list of urls for each group is returned.

Cost

When you run grouped analysis you should be mindful of the cost you are incurring.

Looking again at the properties for the top_urls strategy you can see that the cost is based upon the number of groups specified:

For this strategy the cost is 3 analysis tasks for each group. If you specify 10 groups this will use 30 of your analysis tasks for the hour.