in generalized epidemic settings in East and Southern Africa [3] [4] [5] [6] . The use of social media for socializing and partnerseeking among gay men and other MSM is well-documented and described in many parts of the world [7, 8] . Behavioural interventions delivered on Internet and social media platforms have demonstrated impact on sexual health among MSM in the United States, East Asia and Peru [9] and are adaptable to changing technology and HIV prevention tools [10] . However, despite the severity of HIV epidemics among MSM and TG in parts of SSA [5] and the high prevalence of stigma and discrimination towards MSM and TG in many African countries [4, 25] , sexual health interventions rarely harness this route of HIV prevention delivery and there are few validated online interventions [11, 12] .
There is evidence that MSM in SSA do use social media [13] and many do so to seek partners. Surveys of MSM from urban Lesotho (2011) and eSwatini (2014) found that 39% and 44% of MSM, respectively, reported having met a sexual partner online [14] , and in Nigeria (2013 to 2015), 62% reported having found sexual partners online [15] . Online partner-seeking varied by educational attainment, religion, age, sexual and gender identity and size of social network of MSM.
To further consider the utility of Internet or app-based methods to complement existing approaches to surveillance, intervention delivery and research engagement among MSM and TG in SSA, we need better understanding of online use within broader social and sexual networking. The Internet has been successfully used in other regions to survey MSM [16, 17] , and proved to be a cost-effective method to engage large and broadly representative population samples [18] . In SSA, there are examples of surveys conducted entirely online [19, 20] or that utilize a combination of online surveys and referral from community organizations [21] . However, the representativeness of MSM and TG who socialize online to wider MSM and TG populations in SSA remains unclear, and prompts concern that employing online environments for research sampling or intervention delivery may only reach a relatively affluent and educated sub-population [22] .
Online engagement with MSM and TG populations must also navigate the dual role that social media can play in safety and security [23] . Studies have highlighted how online socializing can be viewed as safer than meeting in physical locations [14] [15] 24 ]. This is unsurprising in a region where same-gender sexual relationships are usually criminalized, and where not, remain highly stigmatized [25] [26] [27] [28] [29] . Physical venues used for socialization in the region are often covert and short-lived as they are targeted by police, authorities or unofficial groups [30] . However, while providing physical security, online socializing and partner-seeking may present other risks that MSM and TG must negotiate, including blackmail from partners met online [24] . How MSM and TG in SSA weigh up and mitigate the risks and benefits of in-person versus online socializing and partner-seeking is currently understudied.
Here we have sought to: (1) examine the extent, nature and means of engagement among MSM and TG individuals who use social media in Johannesburg, South Africa and Nairobi, Kenya; (2) identify their demographic and sexual behaviourrelated characteristics and (3) identify opportunities to use social media settings to facilitate both public health research and health promotion interventions.
We used mixed methods to describe and investigate qualitative and population-representative quantitative survey data collected from MSM and transgender individuals from Nairobi and Johannesburg from 2016 to 2017. MSM and TG were eligible if they were aged at least 18 years; reported consensual sex with a man in the previous 12 months; resided in Johannesburg or within 50 km of Nairobi county; and either currently identified as a man or had been assigned male sex at birth.
We recruited 30 MSM/TG at each site (total n = 60) between May 2016 and July 2017 for an in-depth face-to-face interview. They were purposively selected to provide diversity in age, socio-economic status and ethnicity. Participants were recruited through existing community outreach activities, community organizations and sexual health clinics. Interviews lasting 60 to 90 minutes were conducted in English, Kiswahili (Kenya) or Zulu (South Africa), depending on the preference of the participant, and were audio-recorded, transcribed and translated prior to data coding. In addition to issues relating to sexual health and HIV, the interviews explored how men met and engaged with other men in both physical and online environments.
Respondent-driven sampling (RDS) surveys [31] were conducted in Nairobi (April -December 2017) and Johannesburg (April -November 2017) with intended sample sizes of 600 and 300 respectively. There were 10 initial "seed" participants in Nairobi and nine in Johannesburg (not all productive). Participants were given two coupons for onwards recruitment valid for two weeks. They were reimbursed for their participation and for each enrolled recruit. More detail about RDS recruitment in Johannesburg is given elsewhere [32] .
After screening, participants gave informed consent, privately completed a self-administered questionnaire on a tablet computer, undertook HIV counselling and testing according to national guidelines, and visited a clinician for examination, blood draw and where indicated STI treatment, linkage to HIV treatment services or for pre-exposure prophylaxis. Blood samples were tested for active syphilis (Treponema pallidum haemmaglutination (TPHA) & Rapid Plasma Reagin (RPR) and HIV viral load (GeneXpert HIV-1 VL) if HIV-seropositive.
The questionnaire included sociodemographics, sexual identity and gender identity, online and in-person socializing patterns and social network size (number of adult MSM in the relevant city with whom the participant had spoken in the previous two weeks). For the previous three months, participants reported whether they had sex with a man and/or a woman; what types of sex they had had; and frequencies of condom use during anal and vaginal intercourse. For the previous 12 months they reported: the number of sexual partners they had had; whether they had received money, gifts or favours in exchange for sex with men and with women; and whether they had given gifts, money or favours in exchange for sex with men. Participants reported whether they had experienced urethral or rectal STI symptoms over that period.
Participants self-reported if they had socialized online with other MSM in the previous month; previous year; more than one year ago, or never. If any use was reported, they were asked to indicate all the sites they had visited or apps that they had used in the previous month from a list populated with all sites/apps known to operate in the country, with space to add options. Social media were further categorized as generic (sites/apps in widespread use among the whole population, e.g. Facebook, Instagram), gay-specific (sites/apps targeted to MSM only, e.g. Grindr, Planet Romeo) and dating-specific (sites/apps targeted to users seeking sex or relationships, e.g. Badoo).
Digital recordings of the interviews were transcribed verbatim and translated to English. Debriefing reports were written and discussed after the interview to identify emergent themes. Interview transcripts were subject to a detailed thematic analysis [33] , supported by NVIVO 10. Transcripts were read and re-read by a panel of researchers and interviewers to identify initial codes (relevant or significant features) that comprised the coding framework. The meaning and conceptual distinction of these codes was discussed and agreed upon among the qualitative research team, following which all sections of each transcript were coded using this framework. Data within each code were then carefully reviewed and formulated into higher level themes and cross-referenced against the rest of the coding framework for conceptual clarity.
We report findings from each city separately. All percentages are weighted using RDS-II estimation [34] using the selfreported measure of social network degree. We examined sociodemographic associations with online socializing within the previous month using logistic regression, dropping seed participants and probability weighting by inverse network size, and used Wald tests to assess statistical evidence for associations. We then examined the associations between online socializing and sexual behaviours, first among all MSM and TG in each city, then restricted to those HIV-uninfected to assess the association between online socializing and measures of behavioural HIV acquisition risk. We first examined crude associations, then adjusted for sociodemographic characteristics found to be associated with online socializing and age (Model 1), and finally examined associations with sexual behaviours, partners and STIs among only HIV-uninfected participants (Model 2). For multivariate models, covariates with p < 0.100 in bivariate associations were retained.
Ethical approval was obtained from the London School of Hygiene and Tropical Medicine for both sites, the Human Figure S1 ).
The majority of MSM and TG in Nairobi and Johannesburg were young and self-identified as gay/homosexual and cisgender (Table 1 ). Most had completed secondary education, yet many were unemployed. Most MSM and TG had been sexually active with another man in the previous three months. Nearly two-fifths of men in Nairobi and one-fifth of those in Johannesburg had sold sex to a man within the previous 12 months.
Most participants reported having socialized online with MSM in the previous month, significantly higher in Nairobi than Johannesburg (70.9%; 95% CI 66.5 to 75.0 and 60.1%; 95% CI 53.2 to 66.6 respectively; p < 0.0068). Few reported never having done so: 14.3% in Nairobi and 21.5% in Johannesburg.
The most popular sites/apps used for socializing with MSM in the last month were similar in both cities. Generic social media sites/apps were the most widely used, notably Facebook (53.7% Nairobi; 38.2% Johannesburg) and WhatsApp (46.0% and 42.9%, respectively, Figure 1 ). Fewer participants used gay-or dating-specific apps, nearly all of whom also used generic apps/sites to socialize with MSM ( Figure 1B) . Grindr was the most frequently cited gay-specific service in both cities, used by 8.2% (Nairobi) and 8.1% (Johannesburg) in the previous month.
socializing with MSM in the previous month Few sociodemographic differences were associated with recent online socializing with MSM, and these were inconsistent across cities (Table 2) .
There was no clear association between online socializing and age, nor sexual or gender identity, nor were there strong differences in the sociodemographic profiles of MSM and TG by use of gay-specific or dating apps. (We show usage of sites apps separately by gender identity in Table S3 and Figures S2 and S3.) Those in the second lowest income category in Nairobi were more likely to use gay-specific apps than those in the lowest, but there was no consistent trend. Those born outside of Kenya were more likely to use dating apps Gender identity was assessed using what at the time was considered best practice via a two-step approach [35] , comprising assessment of sex assignment at birth (male, female or prefer not to say) and current gender identity (male, female, transgender or none of these). Alongside recommendations [36] , we described participants as transmasculine where they had been assigned female sex at birth, but now identified as male or transgender, and transfeminine where they had been assigned male sex at birth, but now identified as female or transgender. Participants who did not currently identify as male, female or transgender were described as 'Non-binary'.
compared to MSM and TG born in Nairobi. Students in Johannesburg were more likely than others to use gay apps, and there was variation by neighbourhood, but there was no evidence for a difference by educational attainment or income, (Tables S4 and S5 ).
Evidence for associations between online socializing and sexual behaviour differed between cities (Table 3 ). In Nairobi, socializing with MSM online was more common among those who had: sex with a man in the last three months; receptive anal intercourse in the last three months; more sexual partners; and those who had either bought or sold sex to a man in the last 12 months. Socializing online was less common among those who had sex with a woman in the previous three months. Associations persisted after adjustment (Model 1) and when restricted to HIV-uninfected participants (Model 2), though sex with a man in the last three months was not significant in the latter. In Johannesburg, there was evidence for higher odds of online socializing among those reporting condomless anal intercourse in the last three months (crude model and among those HIV-uninfected), but online socializing was significantly less often reported by participants who purchased sex from a man in the last 12 months, in both adjusted models. While the point estimates for associations between online socializing with men and having had sex with a man, sex with a woman and receptive anal intercourse in the previous three months among MSM and TG in Johannesburg were similar to those observed in Nairobi, the statistical evidence was weaker.
There was no significant difference in online socializing between the proportion of participants reporting STI symptoms or living with HIV by city. However, in Johannesburg, online socializing was associated with active syphilis.
Among MSM and TG who did report socializing online, those reporting some sexual behaviours associated with higher HIV transmission risks did have raised odds of using gay-specific and dating-specific apps, though not uniformly (Tables S6 and S7 ). In Nairobi, MSM and TG with more partners and who sold sex were more likely to report using gay- specific apps, while in Johannesburg the association with selling sex was reversed (though the statistical evidence was somewhat weak). Use of dating apps was associated with both buying and selling sex in Nairobi, but not in Johannesburg. In both settings, socializing with MSM using dating apps was less common among MSM and TG who reported having had sex with a woman.
3.1.6 | Associations between online socializing and engagement with HIV prevention and care technologies No significant associations were detected between online socializing in the last month and use of antiretroviral therapy (ART), virological suppression, recency of HIV testing, PrEPrelated knowledge (among those HIV uninfected or untested) or use or access to condoms or lubricants in either city (Table S1 ).
The sociodemographic characteristics of interview participants were consistent with those of the RDS samples in both cities. The majority (n = 54) of those interviewed reported regular use of social media to engage with other MSM and TG. Two clear themes were identified relevant to the delivery of interventions or research in online spaces.
Participants commonly reported having multiple profiles on generic social media sites: one used for family or work friends and a second for engaging with other MSM. Much use was made of gay or MSM-specific forums, groups and Facebook pages where participants reported how posting within such groups and searching their members for mutual friends was typically a reliable way of identifying other MSM. Posting a photo of oneself and seeing which men "liked" was considered a good initial strategy to online interaction. The use of gay-specific apps was less common, though they enabled a more direct engagement with others known to be MSM. Positioning oneself in such an environment did, however, present its own risks which were often cited as the reason for using generic sites/apps. A number of interviewees also expressed the belief that gay-specific apps remain the purview of MSM described as "higher class. " However, in both contexts, participants described using generic social media sites to find sexual partners, or to buy/sell sex.
Those with less sexual experience or confidence negotiating with men reported this setting as more amenable to flirtation and sexual-planning. More common in both cities, however, was the use of social media to establish friendships, and to alleviate feelings of loneliness or isolation. A small number of men in both cities described how their first forays into MSM bars, clubs, hotels or other hot-spots were facilitated by friendships originally made in online environments.
For many participants across both cities, interacting with men in social media environments was considered safer than attending physical locations where MSM congregate. This was especially true for participants in Kenya who reported that police raids or general hostility towards gay bars or hotspots were commonplace. However, while facilitating a broad range of social and sexual connectivity, social media apps and sites were not without their own risks.
Concerns were raised by participants in both cities regarding the possibility for "context collapse" [25] . This notion refers to when different aspects of one's life and experience, which are usually kept separate in the physical world, come to overlap in online environments; for example, circumstances where a man's family is unaware or disapproving of his attraction to men, this could be threatening. While having multiple profiles was a common strategy to avoid this occurrence, the risk remained. Particular concern was raised for pictures shared (especially sex-related images) and how these might come to the attention of non-MSM friends and family or be used for the purposes of blackmail. "In social media the majority of them are looking for money. The others are blackmailers. " [Aged 22, Nairobi]. Indeed, a concern for blackmail was pervasive among many, such that some were hesitant to share any personal information or images of themselves until they felt "safe" with the person(s) they were interacting with online. Ultimately choosing to meet face-to-face was challenged by these concerns. Risk mitigation strategies included "screening" the person online with questions about sex between men to ensure they were "legitimate" MSM, requesting that they send multiple photographs of themselves to ensure they had not simply adopted another person's photograph), and actively discussing physical safety concerns before meeting. 
Use of social media to socialize with MSM was common among MSM and TG in Nairobi and Johannesburg, with a majority among population-representative samples reporting having done so recently. Those socializing online showed a wide diversity of characteristics and clear HIV prevention and sexual health needs. MSM and TG used different platforms, but generic socializing apps/sites were most common, while use of gay-specific and dating apps/sites were less prevalent, a pattern also seen amongst MSM seeking partners online in Nigeria [15] . All types of social media were used for partnerseeking as well as socializing, but the role that social media plays in providing anonymity and security in the context of criminalizing and socially stigmatizing settings is complex.
Online socializing with MSM was not restricted to particular subgroups of socio-economic status, age or sexual and gender identity. Nor was there good evidence that this varied very much by type of app, and the distribution of their use was very similar across cities. This is important because it suggests that a representative diversity of MSM and TG in each city might be reached via social media channels. There was some evidence that among MSM and TG in Nairobi online socializing was more common among those with at least a secondary education, compared to none or primary, but the use was high across all education groups. Although not directly comparable, our findings are unlike earlier surveys from Swaziland, Lesotho and Nigeria, in which online partner-seeking was strongly associated with higher education and younger age [14, 15] . There was some evidence that social media use was higher amongst those who were born outside of Johannesburg, compared to those born in the city. This may reflect lower accessibility or tolerance of offline MSM communities outside of large cities, as reported in rural and semi-rural parts of Mpumalanga, South Africa [22] .
Our findings confirm that MSM and TG who are active online have unmet needs for sexual health information, services and referral. In both cities, MSM and TG socializing online reported high levels of HIV and STI transmission behaviours, yet we found no evidence they were more engaged in HIV prevention or care. The latter observation differs from studies in the United States suggesting that whilst Grindr users may engage in higher risk behaviours than non-users, they also report higher uptake of prevention (PrEP use [37] ) and HIV testing [7] ). The delivery of HIV-related education as well as signposting to HIV testing venues via engagement with MSM in social media (often termed "Netreach") has been shown effective in several countries [38, 39] , whereas social media facilitated HIV testing (e.g. for home-based self-testing or self-sampling) has shown early promise as acceptable and feasible [40] .
Effective and convenient sexual health promotion and service models facilitated by social media have been developed in high-resource settings, and such models typically expand user choice beyond traditional, facility-based services rather than replacing existing models completely [12] . Online interventions might help in mitigating the effects of healthcare associated stigma via facilitating better choice among services by enabling peer service reviews, for example [30, 41] . Site/appbased channels of communication provide an additional option for peer support interventions, for instance, those aiming to improve ART adherence [42] . Importantly, our findings suggest that a sizeable minority of MSM and TG are not regularly active online (40% in Johannesburg, 30% in Nairobi). Some may not have access to the necessary technology, however, our qualitative findings indicate that for some, the risks of establishing a presence online are perceived to be greater than the benefits [24, 43] . Providers planning online services and interventions must be aware of and mitigate what may be unfamiliar risks, and should anticipate that such services will not be acceptable to all. Furthermore, the design of online interventions or intervention components need to consider the role of syndemics of mental health disorders, substance use and experience of harassment and abuse, which are part of the context in which sexual behaviours and risks among MSM and TG in Kenya and South Africa occur [44] [45] [46] [47] , but which vary across settings [48] . A systematic review of substance use among African MSM found that use of recreational drugs and alcohol were frequently used as part of sexual experiences [49] . The ways in which these factors interact with the motivations for and experiences of online socializing and partner seeking among MSM and TG in Kenya and South Africa should be further explored to inform the targeting and design of intervention packages to address them.
We found some strong similarities in online socializing with MSM across the two cities, with similar types of site/apps used and concordance on the motivations for their use. Some differences in the associations with sexual behaviours may arise from differences in sample power, or different population prevalence of STIs (e.g. active syphilis is more prevalent in Johannesburg than Nairobi). There were different patterns associated with sexual exchange in each city, but this also varied substantially in prevalence; buying and selling of sex was twice as common among MSM and TG in Nairobi as in Johannesburg. The relative usefulness and strategies for using social media for engaging MSM and TG engaged in transactional sex might differ across cities.
A strength of our approach was the use of a representative survey method that permitted the comparison of those who are, and are not, socializing online (which cannot be accomplished in an online-only survey). The qualitative data aid interpretation and make clear that, while not without its own challenges, online socializing helps facilitate in contexts of social censure. However, as a cross-sectional survey, we are unable to determine causality relating to the experiences that influence social media use, nor infer direction of association between social media use and HIV transmission risk behaviours. Both study sites were urban and findings are not necessarily generalizable to rural areas. While widely used to obtain population-representative estimates among MSM in SSA [40] , assumptions underlying RDS estimation are difficult to meet in practice [51] . This survey lacked the power to explore issues specific to transgender participants and we acknowledge the need for such work. While there were lower percentages of transfeminine persons reporting use of gayspecific and dating sites/apps in the last month, we did not find statistical evidence for differences in use of sites/apps to socialize with MSM in the last month by gender identity. Finally, the use of specific sites/apps changes quickly over time, but there is little more recent literature documenting and investigating online socializing among MSM and TG across SSA. In trying to understand motivations behind usage we hope that the data will be more enduringly informative.
Online environments are widely used by African MSM and TG to socialize and partner-seek, and offer routes to deliver sexual health promotion, services and research opportunities that are currently under-utilized. The lack of demographic variation in social media use suggests that access is not limited to those with higher socio-economic status only. While evidence of an elevated HIV risk profile among those using social media may complicate the use of Internet-facilitated samples to estimate HIV prevalence, MSM and TG recruited online may provide valuable insight into the factors that influence risk behaviour as well as uptake/engagement with HIV testing, care and prevention interventions. In addition, these data strengthen the evidence base for delivery of health education, social marketing and peer support programmes in online spaces. Since 2017, overall access to online sites/apps has likely increased and it is unlikely that the diversity of MSM and TG using them has narrowed. It is also possible that disruptions both to in-person HIV and sexual health services, as well as to the options available for socializing amongst MSM and TG caused by the COVID-19 pandemic and associated physical distancing policies further strengthen the need for online site/app mediated interventions. While needing to be attentive to concerns relating to context collapse and blackmail or digital security, community-based organizations in particular are well-placed to deliver online interventions at scale, potentially side-stepping some of the traditional challenges inherent in reaching MSM and TG in hostile social environments that often present physical safety concerns. 
EF contributed to conceiving and designing the study and data collection instruments, carried out quantitative analyses and drafting of the manuscript; AB contributed to conceiving and designing the study and data collection instruments, carried out qualitative analyses and drafting of the manuscript; ST and RK contributed to managing data collection, conducted interviews and approved the final draft; ADS contributed to designing the study, data collection instruments, carried out quantitative analyses, commented on and approved the final draft; WN helped design the data collection instruments, analysed qualitative data and approved the final draft; JK, PW and TPP contributed to conceiving and designing the study and data collection instruments, commented on the manuscript and approved the final draft. All authors have approved the final manuscript.
We thank and acknowledge the participants of the TRANSFORM study, and are grateful to our community-based partners, ANOVA Health Institute, Ten81 and SOHACA in Johannesburg and GALCK, HOYMAS and ISHTAR in Nairobi.
This study was funded through the Evidence for HIV prevention in Southern Africa programme, funded by UK aid from the Department for International Development, and Sweden, through the Swedish International Development Agency (SIDA), mandated to represent the Norwegian Agency for Development Cooperation (Norad), and managed by Mott Macdonald. Further analyses were funded via the Medical Research Council grant number MR/S020462/1. The funders played no role in this reporting of findings.
Additional Supporting Information may be found in the online version of this article: Figure S1 . Convergence of the estimate of the proportion of MSM/TG in Nairobi and Johannesburg who report having socialised online in the previous month. Figure S2 . Sites and App usage in Nairobi in the previous month by gender identity. Figure S3 . Sites and App usage in Johannesburg in the previous month by gender identity. Table S1 . Associations between frequency of online socialising and engagement with HIV prevention and care technologies Table S2 . Demographic characteristics of qualitative interview participants Table S3 . Online socialising with MSM in the last month by gender identity Table S4 . Sociodemographic characteristics associated with socialising with MSM in the last month using gay-specific apps, among MSM/TG who had socialised online in the last month Table S5 . Sociodemographic characteristics associated with socialising with MSM in the last month using dating-specific apps, among MSM/TG who had socialised online in the last month Table S6 . Sexual behaviours and STIs associated with socialising with MSM in the last month using gay-specific apps, among MSM/TG who had socialised online in the last month Table S7 . Sexual behaviours and STIs associated with socialising with MSM in the last month using dating-specific apps, among MSM/TG who had socialised online in the last month