A computer program product comprising a computer readable storage medium having instructions encoded thereon that, when executed by a processor, cause the processor to:
- receive information describing locations of client devices associated with a plurality of users of an online system;
- identify a group of users of the online system based at least in part on one or more connections between the users and the information describing locations of client devices associated with the users during a time interval, wherein a client device associated with each user of the group is within a threshold distance of a client device associated with each additional user of the group for at least a threshold amount of time;
- predict a purpose of the group based at least in part on information stored in association with the one or more connections between the users and a geographic location associated with the users during the time interval;
- predict a common interest shared by the users of the group based at least in part on a comparison of information maintained by the online system associated with each user of the group;
- determine a plurality of candidate content items that may be presented to one or more users of the group, each of the plurality of candidate content items associated with a purpose having at least a threshold measure of similarity to the predicted purpose of the group and an interest having at least a threshold measure of similarity to the predicted common interest shared by the users of the group;
- compute a score for each of the plurality of candidate content items based at least in part on a measure of similarity of the purpose associated with the candidate content item to the predicted purpose of the group and a measure of similarity of the interest associated with the candidate content item to the predicted common interest shared by the users of the group;
- select one or more content items from the plurality of candidate content items for presentation to the one or more users of the group based at least in part on the scores;
- and
- present the one or more content items to the one or more users of the group.