SP.UserProfiles.PeopleManager.getTrendingTags Method (sp.userprofiles)

Gets the most popular tags. getTrendingTags is a static method.

Applies to: apps for SharePoint | Office 365 | SharePoint Foundation 2013 | SharePoint Server 2013



Return value

The 20 most popular hash tags over the past week, sorted so that the most popular tag appears first.


The following code example gets the trending tags in the current context.

var trendingTags;

// Ensure that the SP.UserProfiles.js file is loaded before the custom code runs.
SP.SOD.executeOrDelayUntilScriptLoaded(getTrendingTags, 'SP.UserProfiles.js');

function getTrendingTags() {

    // Get the current client context and call the getTrendingTags static method.
    var clientContext = new SP.ClientContext.get_current();
    trendingTags = new SP.UserProfiles.PeopleManager.getTrendingTags(clientContext);

    // Load the query and send the request.
    clientContext.executeQueryAsync(onRequestSuccess, onRequestFail);

// This function runs if the executeQueryAsync call succeeds.
function onRequestSuccess() {

    // Get trending tag information.
    alert('There are ' + trendingTags.get_count() + ' trending tags.');
    alert('The name of the first tag is ' + trendingTags.itemAt(0).get_name());
    alert('The use count of the first tag is ' + trendingTags.get_item(0).get_useCount());

// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
    alert('Error: ' + args.get_message());

See also

Other resources