Introduction

Several major terror attacks conducted in the name of political Islam have hit Europe in recent yearsFootnote 1, some of these attacks resulting in dozens of fatalities. In addition to the devastating consequences for those directly affected, such attacks also have an impact on inter-group relations in European societies, in that public speakers and political elites sometimes cite mass immigration as a contributory factor [2, 3]. In turn, Muslims in Europe have reported a rise in perceived discrimination [4] and a decline in mental health and wellbeing [5] after Jihadist terror attacks. On the side of the majority population, existing evidence regarding the impact of terrorism on attitudes toward immigration and immigrants is mixed. While some studies found no evidence for a relationship between terrorist attacks and such attitudes [e.g.: 6,7], others have shown more negative public attitudes toward immigrants [e.g.: 8,9,10,11,12,13] or higher exposure to online hate speech [14] after attacks. Most of these studies are based on survey data and consequently have methodological limitations, such as being too coarse to measure the time-sensitive effects, being restricted to predefined survey items, or social desirability bias [see 15]. Complementing existing survey research, this paper sets out to overcome these limitations by studying changes in ethnic and religious hostility expressed on social mediaFootnote 2. For the context of the study, we define ethno-religious hostility as aggressive, antagonistic, or negative interactions and rhetoric aimed at ethno-religious minorities or migrants, often characterized by prejudice, xenophobia, and discrimination. Specifically, we ask: Does ethno-religious hostility on social media increase after terror attacks? We use time-stamped data capturing commenting behavior in over 4.5 million Tweets, posted by about 1.2 million different users across five European countries, before and after ten major terror attacks.

In doing so, this study also speaks to the literature on the stability of attitudes. Scholars have recently argued that attitudes and values are mostly stable over the life course [17, but see 18]—including attitudes toward immigration [19]. Following this reasoning, attitudes are largely formed during the formative years of adolescence and early adulthood [20, 21]. While a life course perspective is clearly beyond the scope of the present study, we have set out to test whether sudden events of terrorism contribute to short-term changes in expressions of hostility by individual users of a social media platform, and how fast these changes abate. The advantage of this approach lies in analyzing opinions and their shifts at the precise moment a person decides to express them (i.e., chooses to Tweet) rather than relying on scheduled interviews using pre-set questionnaires, as with survey data collection.

Beyond methodological benefits in studying changes in ethno-religious hostility expressed on a social media platform, Twitter is a meaningful field of study for social scientists given its positioning as a “digital socioscope” [22 (p. 1)] or “online marketplace of ideas” [23], one that plays an important role for public and political discourse. Social science research has recently come to appreciate Twitter data as a means of testing theories that hitherto had mainly been examined empirically in the context of survey data analysis. In the area of public attitudes toward immigration and immigrants, a pioneering example is the study of Menshikova and van Tubergen [24], who tested the predictions of group threat theory (see below) using Twitter. Mirroring findings from attitudinal survey research [25,26,27], Menshikova and van Tubergen [24] reported more negative Tweets on immigration when the topic is salient in the news. Following this path, we employed Twitter to test the impact of terrorist attacks on ethno-religious hostility. While this effect has been extensively studied in the context of survey research [for example: 8,9,10,11,12,13], it has received limited attention in research on social media. Our goal is to analyze, from a computational social science perspective, the much-debated hypothesis that terrorism shapes anti-immigrant attitudes.

More broadly, analyzing shifts in social media debates is also important because hostile discussions on social media can influence the reporting of traditional news outlets, as suggested by intermedia agenda-setting theory [28, 29]. Likewise, online language use can have consequences with respect to offline behavior. For example, the level of online hate speech has been shown to correlate with the vote share of far-right parties [30]. Even more dramatically, hate speech against refugees on Facebook has also predicted anti-refugee violence in Germany [31].

The impact of Islamist terrorism on ethno-religious hostility

Group threat theory contends that negative attitudes and hostile behavior toward out-groups (e.g., immigrants, ethnic and religious minorities) are the result of the impression that minority members pose a threat to the interests of a given society’s majority group [32, 33]. In his seminal paper on racial prejudice as a sense of group position, Herbert Blumer [34] argues that important events play a key role in the development of exclusionary and discriminatory views toward out-group populations because such events contribute to a particular majority’s perception of the minority group and intergroup relations. Blumer argues that events “loaded with great collective significance”, which feed into representations of the minority group as a threat in public discussions, are “particularly potent in shaping the sense of social position” [34 (p. 6)]. Terror attacks certainly fall into the category of such significant events, as they pose a threat to individual and collective safety as well as to social norms, and are often blamed on immigrants in general and Muslim immigrants in particular. Thus, terror attacks in the name of political Islam can have the power to shape attitudes toward immigrants and Muslims.

The theoretical prediction of group threat theory — that terror attacks lead to more exclusionary attitudes among the majority population — has been tested extensively by social scientists. This body of research can be grouped into three categories: Natural experiments based on secondary survey data; studies based on self-collected survey data; and papers drawing from digital trace data.

The first set of studies exploits the fact that several large survey programs happened, unintentionally, to be active in the field at the time of such terror attacks. The timing of these attacks, being exogenous, resembles a natural experiment. Based on such a design, several studies have reported more unfavorable sentiments toward immigrants after attacks [5, 8,9,10,11,12,13, 35, 36]. However, the claimed magnitude of this impact varies across cases. Some studies even reported null effects [6, 7, 37, 38].

A second set of studies is based on self-collected data specifically designed to capture the way people perceive the shifts in social media debates following terror attacks. For example, Kaakinen, Oksanen, and Räsänen [14] showed that young Finns reported being exposed significantly more often to online hate speech after the November 2015 Paris attacks; Oksanen and colleagues [39] demonstrated that exposure to online hate speech after this attack correlated with the perception that one’s society is characterized by fear. Based on a self-designed online forum that systematically varied existing comments, Álvarez-Benjumea and Winter [40] showed that expressions of online hate speech toward refugees after terror attacks tend to be conditional on the normative context of a platform.

Very few studies directly examined the impact of terror attacks on online behavior by drawing from digital trace data (i.e., social media data analyses). Employing topic modeling on 51,000 German Tweets posted in the week after the Berlin attack of 2016, Fischer-Preßler, Schwemmer, and Fischbach [41] found that Tweets expressed sympathy for victims but also nationalistic sentiments. Czymara et al. [42] showed, based on over 100,000 YouTube comments on immigration-related issues before and after a set of attacks, that ethnic insulting was more present after attacks. Analyzing 11 events related to terrorism and crime, Giavazzi et al. [30] showed the language used on German Twitter became more similar to the language used by the right-wing Alternative für Deutschland (AfD) party after such events. Finally, Jović et al. [43], analyzing views of Wikipedia pages before and after attacks, demonstrated that attacks boosted attention to pages on content related to the attackers (such as terrorism or Islam), as well as to pages on security and self-perception (such as the national or religious identities of one’s society). This underscores the importance of Islamist attacks for processes of boundary-making in Western countries. In sum, these considerations lead us to expect that:

Hypothesis 1

Hostility on social media increases after terror attacks.

However, the effect of terrorism on social media debates is likely to change over time. Prior research proposes that online communication in times of crisis follows Pennebaker’s model [44], which consists of three stages: emergency, inhibition, and adaptation [45]. The emergency phase features heightened anxiety and more talk about the crisis event, followed by a decrease in discussion during the inhibition phase, and finally, the adaptation phase signifies a return to normalcy, indicating the community has psychologically moved past the incident [45]. In the context of the Paris terrorist attacks in November 2015, Garcia and Rimé, [46] show an immediate surge in negative affect in Tweets, including anxiety, sadness, and anger, after the attack, which leveled off within several days. However, the rise in increased solidarity after the attack was long-term [46] - a pattern consistent with the response to other types of disasters [47]. Attitudinal survey studies have also shown that the potential effects of terrorism on hostility tend to be short-lived [10] and abate over time [11]. Turkoglu and Chadefaux [38] reported that the effects of attacks on attitudes toward immigration disappear within two weeks. Similarly, Helbling and Meierrieks [48] concluded in their review paper that the effects of terrorism on anti-immigration attitudes tend to be short-lived. We expect that online discussions on immigration-related topics after terrorist attacks follow a similar trajectory as in [45, 46]. This implies that the immediate increase in hostility levels should weaken over several days and, ultimately, return to baseline levels. We formulate the following hypothesis:

Hypothesis 2

The effect postulated in H1 levels off over several days.

On a conceptual level, it is likely that Jihadist terror attacks do not affect views and behavior toward all immigrants equally. Rather, prejudice is dependent on the degree to which a group is seen as threatening within a particular social context [49]. People differentiate between different minority groups when forming their opinions; as a consequence, attitudes toward different groups are associated with different predictors [50, 51]. Jihadist attacks are perceived as most directly connected to Muslims because such attacks are motivated by political Islam. Thus, views toward Muslims are most likely to be affected by such attacks [52]. However, there might also be a generalization toward public views of immigration more broadly. This is because terrorism is sometimes blamed on immigration in general (see [48] for an overview). Viktor Orbán, Hungary’s right-wing prime minister, referenced this in a comment that “all the terrorists are migrants” [2]. We hence expect a specific as well as a generalized component in the increase of ethno-religious hostility after attacks.

Hypothesis 3a

Islamist attacks have the strongest effect on Tweets about Muslims.

Hypothesis 3b

There is a spillover effect onto Tweets about immigration in general, even if such Tweets do not mention Muslims or Islam.

Finally, we want to test the mechanisms that cause the rise of hostility on social media after attacks. The argumentation of group threat theory implies an attitudinal change in responses to threatening events such as terrorist attacks [11]. However, some research has questioned whether immigration attitudes react to such shocks [19]. More broadly, Kiley and Vaisey [17] argue that “personal culture”, i.e., an individual’s “attitudes, worldviews, values, dispositions, and associations” [17 (p. 478)], is mostly stable over one’s life course [but see 18 for a counterargument]. If this is true, any observed differences over time should be driven by disparities between people expressing their opinions at different time points—that is, interpersonal differences that perhaps appear due to socialization processes [20, 21]—and not because people revise their views and change their behavior. In the context of this study, this means that higher levels of ethno-religious hostility after terror attacks would be driven by differences in the composition of users who post before and after an attack. Put differently, more hostile commenters join the discussion due to an attack while more peaceful ones may leave. The competing hypothesis is that individual users actually update their views— and thus become more hostile in their Tweets.

Existing research on social media data mainly favors the explanation of composition effects [42, 54, 55]. However, these studies have not provided a sensitive test of within-user changes in posting on social media platforms following a terror attack. Flores [54], for example, did not examine terrorist attacks but rather the influence of the introduction of an anti-immigration law in the US on Twitter. In contrast, Spörlein and Schlueter [55] and Czymara et al. [42] both analyzed data from YouTube comments on immigration issues made before and after terrorist attacks. However, YouTube is structurally different from Twitter: while debates on Twitter are often highly interactive, users might post only a single comment under a given video on YouTube. This complicates the identification of changes in the content of individual user’s comments on YouTube. Czymara et al. [42] reflected this by observing that “most users who comment before a terror attack do not comment after an attack, which renders a general statement on within-user change complicated” [42 (p. 546)]. We believe that Twitter’s vivid and interactive culture makes it an ideal platform to test the question of whether individual users actually become more hostile on social media due to significant events. Thus, to understand the sources of the rise in ethno-religious hostility in the aftermath of terrorist attacks, we ask whether individual users became more hostile, and formulated the following hypothesis:

Hypothesis 4

Within users’ hostility increases after terror attacks.

To put Hypothesis 4 in other words, the Tweets of the same users will be more hostile after attacks than before attacks.

Data and method

Selection of cases

We draw upon Tweets dealing with immigration and related topics such as refugees, asylum, Muslims, and Islam, posted in the week before and after ten major Islamist terror attacks in Europe.Footnote 3 We included all major terrorist attacks that took place in Europe after the establishment of Twitter, defined as attacks that killed at least five and injured more than ten people.Footnote 4 For each attack, we removed Tweets posted in the first 30 min after the attack, to ensure that information about the attack was already circulating and to ensure that Tweets analyzed were in reaction to the event in question. Table 1 gives an overview of the attacks that were included in the analysis. All code is available on the Open Science Framework: https://osf.io/zdt5b.

Table 1 Overview of attacks

All Tweets were collected between December 2022 and January 2023 from the v2 API endpoint for the Academic Research Product Track using [56]. The goal was to identify original Tweets concerned with immigration-related topics. To this end, we used a language-specific search string including keywords such as “immigration”, “foreigners”, and “refugees”. Tweets were collected when they included at least one of these keywords. Moreover, we included the terms “Muslims” and “Islam” because, in the European context, Muslims are quite possibly the most debated immigrant group.Footnote 5 However, we excluded terms that have a strong connotation with terrorism (e.g., “Jihad”, “Islamist”). Likewise, we did not directly search for insults, derogatory terms, and neither for attack-specific hashtags, as these are only plausible for the period after an attack. For each term, we searched for its direct appearance in a Tweet as well as its hashtag. The English search string was translated into French, German, and Spanish by native speakers. We used language-specific queries for each case but decided against restricting our sample to accounts sharing their locations. When applicable, we used singular, plural, male, and female versions of the relevant terms. To test Hypotheses 3a and 3b, we re-ran the models excluding those Tweets that mentioned terms relating to Muslims or Islam. We did not include Retweets in our sample as they do not constitute original content. This strategy yielded a data set of 4,596,300 Tweets.

Generally, Tweets about migrants, refugees, and Muslims increased strongly after attacks but leveled off over time. Fig 1 displays this trend for the pooled data by showing the number of Tweets per minute before and after an attack. There is a clear spike shortly after the attacks, where the aggregated number rises to over 850 Tweets per minute. This trend then levels off over time. Table 2 shows that the data are skewed toward the three cases from the UK, which make up about 75% of the overall data. This is to be expected though; the English-speaking public is by far the largest one on Twitter. The fewest Tweets came from the German attack, which makes up 0.9% of the overall data. Importantly for this study, all cases follow patterns similar to that in Fig. 1, albeit on different levels overall (see Table 2 or Fig A1 in the supplementary material).

Fig. 1
figure 1

Global distribution of Tweets

Table 2 Distribution of Tweets by case

Sample

At the time of data collection, the 1,192,909 users included in our sample had, on average, 8,028 followers, followed 1,230 users, and had a median of 8,435 posted Tweets. This implies that the users in our sample are somewhat more connected than the full 24-hour sample collected by [22] in September 2022. However, the distribution of these characteristics is skewed, especially concerning the number of followers. While 25% of users have 89 followers or fewer, 68 users have more than 10 million followers. Fig A2 in the supplementary material plots the distribution of these attributes. Only 4% of the users were verified users (47,753 in total). In the robustness checks, we ran the analyses for certain subsets of the sample.

Measuring ethno-religious hostility

We employ the Perspective API of Google Jigsaw’s Conversation AI, which is based on convolutional neural networks [58] and is “trained to recognize a variety of attributes (e.g. whether a comment is toxic, threatening, insulting, off-topic, etc.) using millions of examples gathered from several online platforms and reviewed by human annotators” [59]. We applied the API to our Tweets using [57] between December 2022 and February 2023. In particular, we use API’s IDENTITY_ATTACK attribute to measure ethno-religious hostility. This attribute was designed to measure “Negative or hateful comments targeting someone because of their identity” [59]. In this context, we assume that identity proxies ethnicity, race, or religion (similar to [42]). In the models below, we use the continuous version of the outcome provided by the Perspective API, which measures from 0 to 100% the probability that a comment is hostile. Averaged over the whole data, the probability that a Tweet is hostile by this definition is 21.6%. In alternative approaches, we ran the same analyses for binary versions of this variable (see robustness checks).

To validate the results obtained through Jigsaw’s API, we drew a random sample of about 2,000 Tweets, stratified by case, the before-after period, and the predicted hostility (oversampling Tweets with a predicted probability of 0.75). We then employed ChatGPT 3.5, which has been shown to mirror well the judgment of human coders (usually considered the gold standard) [60, 61] or even exceed it [62]. As proposed by Gilardi and colleagues [60], we developed instructions for ChatGPT and fed each Tweet with the same instruction one by one (see the supplementary material for details). This was done twice for each Tweet in May 2023. The results show that the predictions of both approaches correlate highly (r = 0.8). As another reliability metric, we calculated the Intra Class Correlation Coefficient, which shows 77% agreement with Perspective and either one GPT prediction. To check whether our approach is also valid for the highest levels of hostility, we categorized hostility probabilities as 0 ( < = 90%) and 1 (> 90%) and calculated F1 scores.Footnote 6 This led to an F1 score of 0.9, with a precision of 0.98 and a recall of 0.82. Thus, in all metrics, our approach appears to be reliable. We assume that the two algorithms are largely independent, as they follow a different logic and are mostly based on different training data. This, in combination with the fact that ChatGPT has already performed well with other tasks, gives us the confidence that our machine-learning predictions are well suited to capturing a Tweet’s hostility accurately.

Statistical models

We employ Ordinary Least Squares to compare the average value of ethno-religious hostility in the week before and after an attack, as captured by a dummy variable (attack). This is a straightforward test of our first hypothesis. However, a simple before/after comparison would not take into account different trends in hostility in the two periods. To test for differences in trends, we add a running variable (time_since_attack) counting the minutes until and after an attack—roughly ranging from − 10,000 min (7 days before) to + 10,000 min (7 days after). We use this variable and interaction term between the attack dummy variable and time_since_attack variable to perform an interrupted time series analysis. This way, we can test the effect directly after attacks for our first hypothesis and the trend afterward for our second hypothesis. In particular, the underlying equation is:

$$\eqalign{ p\left( {hostility} \right) = & {\beta _0} + {\beta _1}attack + {\beta _2}time\_since\_attack \cr & + {\beta _3}(attack \times time\_since\_attack) + {\beta _4}case + \varepsilon \cr}$$

Where \({\beta }_{1}\) is the immediate attack effect on hostility (i.e., at time point 0), \({\beta }_{2}\) captures potential time trends in hostility before an attack (i.e., conditional on attack = 0), \({\beta }_{3}\) models the trend after the attack, and \({\beta }_{4}\) captures differences across the ten cases. For Hypotheses 3a and 3b, we re-estimate this model for the subset of Tweets that does not mention Muslims or Islam at all.

To examine the generalizability of Hypotheses 1 and 2, we employ models that allow both the attack effect and the trends to vary across cases. This implies a three-way interaction model between the attack dummy, the time variable, and the case variable. The equation of this model is the following (note that the required two-way interaction terms are excluded from the equation for simplicity, but included in the estimated models):

$$\begin{aligned} p\left(hostility\right)=&{\beta }_{0}+{\beta }_{1}attack+{\beta }_{2}time\_since\_attack+{\beta }_{3}case\\&+\cdots \left[twoway interaction terms\right]\cdots \\&+{\beta }_{4}(attack\times time\_since\_attack\times case)\\&+{\beta }_{5}case+\epsilon\end{aligned}$$

This model is largely analogous to the one above, with \({\beta }_{4}\) in this equation modeling how the after trend varies across the ten cases. As the interpretation of the parameters in three-way interactions is quite complex, we plot the results below and summarize the main findings. The full table of results is available in the supplementary material. In all models, we cluster standard errors on the user level to account for autocorrelation using [63].

Finally, we run user-level fixed effects models (FE) to analyze changes in the Tweeting behavior within users over time, which allows us to test Hypothesis 4 on the mechanisms underlying shifts in hostility levels after attacks. These FE models allow us to inspect whether individual users indeed became more hostile after attacks. FEs offer the strong benefit of automatically controlling for all time constant or slow characteristics on the user level. This does imply, however, analyzing only the subset of 324,519 users who Tweeted both before and after an attack—approximately 27% of the users in our overall data set.

Results

The simple comparison of the before and after attack Tweets in Model M1 of Table 3 shows that Tweets are indeed more hostile after the attacks (full model in Table A1 in the supplementary material). In the aggregate, the average probability that a Tweet is hostile is 5.4% points higher after an attack on the 0–100-point scale.

To test whether there are different trends in the before and after attack periods, we perform an interrupted time series analysis (M2 in Table 3). As expected, the results show a negligible and statistically non-significant trend before the attack (beta = − 0.000001, p = 0.851), a 9.9% points jump toward hostility at the time of the attack, and a -0.001 trend after the attack. As the running variable is measured in minutes, this implies that the attack effect weakens, on average, by 0.06 points per hour after the attack, or by 1.44 points per day. Consequently, the boost in hostility due to the attack is expected to have leveled off about seven days after an attack. These findings are in line with both Hypotheses 1 and 2.

Table 3 Regression models

Next, we examine how these findings differ across cases by adding a three-way interaction between the attack dummy, the time variable, and the cases (full model shown in Table A1 in the supplementary material). Results of this model reveal some variation in both the effect of the attack itself and the trends. Fig 2 shows that the attack effect ranges from 15.3 points in the case of the Barcelona attack to 6.91 for the Strasbourg attack—the most recent attack in our data. All cases have a negative trend in the after period (from − 0.08 points per hour for the Manchester attacks to -0.04 for the Strasbourg attack). This signals that the impact of an attack is relatively short-lived and, in all cases, returns to its initial value a few days after an attack. Differences across cases notwithstanding, the results support Hypotheses 1 and 2.

Fig. 2
figure 2

Trends and changes in ethno-religious hostility before and after terror attacks by case. Note The red line represents the average predicted hostility in Tweets over time, with minutes before and after an attack on the x-axis and hostility levels on the y-axis. Zero on the x-axis pertains to the time of the attack. Each circle represents a Tweet; darker shades signify a higher concentration of Tweets. The lines below each case plot illustrate time trends in Tweet density

To test Hypotheses 3a and 3b on the specific and general components of ethno-religious hostility, we ran the models on a subset of Tweets concerned with immigration-related issues, but which do not mention Muslims or Islam at all. Thus, if a Tweet discussed immigration in general, but also mentioned Islam-related terms at some point, it was excluded from this sub-analysis. This leaves about 20% of the Tweets and a new data set of 909,841 Tweets. Given the nature of the events under investigation, it is not surprising that a significant share of Tweets mentions Muslims or Islam-related terms at some point. However, we now turn to the subset of Tweets that do not mention any such terms, but rather discuss more general immigration-related issues. The results are in M3 of Table 3. We find similar, but slightly weaker attack effects when excluding Tweets mentioning Muslims or Islam. In this subset, the hostility rises by about 8.16 points during an attack and levels off after 7.2 days. Hence, while the increase in hostility is strongest for Tweets referring to Muslims and Islam (in line with Hypothesis 3a), we do also observe a substantial and statistically significant effect for the general immigration discourse that does not at all mention Muslims or Islam (in line with Hypothesis 3b).

As a final step, we estimate a user-level fixed effects (FE) model to analyze changes in the hostility of Tweets within users. To account for the fact that some users posted during several attacks, we again control for case differences in these models. The FE estimate for the comparison of the average hostility before and after terror attacks shows that such attacks indeed changed the behavior of the same users. The average probability of posting a hostile Tweet is 1.95% points higher after an attack than before (M1 in Table 4). However, this is less than half of the estimated effect of the attack in the pooled model reported above (M1 in Table 3), which amounted to 5.4% points. Although individual users become more hostile in response to attacks, compositional differences (i.e., different users posting before and after attacks) make also a significant contribution to the rise of levels of hostility on Twitter in the aftermath of attacks.

When adding time trends to the user-level fixed effects (FE) model, we observe a 3.6% point rise in hostility immediately after the attack (M2 in Table 4). The fixed effect within users again accounts for only part of the overall effect of 9.9% points reported above in the pooled model including time trends (M2 in Table 3). Yet, overall, the results confirm Hypothesis 4, suggesting that the same users post more hostile Tweets after attacks than before.

Table 4 User-level fixed effects models

Interacting the effect of the attacks with the case variable in the user FE model shows again some interesting heterogeneity. While the Tweeting hostility of users changed most after the German attack with an increase of 3.54 points, it is weakest in the case of the Westminster Bridge attack, with an increase of 1.42% points (see the first model in Table A2 in the supplementary material). However, in all cases, the effect remains positive and statistically significant (p < 0.001). For the immediate effect directly after the attack, the estimate is again strongest for Germany with an increase of 5.73% points, and weakest for the Manchester bombing in 2017, with an increase of 2.1 points (all p < 0.001 see the second model in Table A2 in the supplementary material).

Robustness checks and plausibility tests

One could argue that whether or not a Tweet is hostile is a categorical characteristic. As an alternative dependent variable, we dichotomized the probability into a dummy variable with values 0 (not hostile) for Tweets with a probability below or equal to 75% and 1 (hostile) for those with a probability above 75%. As an alternative to this, we also created the same variable but with a threshold of 90%. We then regressed these outcomes on the predictors using a binomial link function. The results mirror the findings reported above: while there is a flat, statistically insignificant trend in the before period, ethno-religious hostility spikes at the time of the attack and levels off after. For the 75% threshold version of the dependent variable, the chance that a Tweet is ethno-religiously hostile is 2.9 times higher after the attack. Interestingly, this effect is somewhat smaller for the 90% threshold outcome, with an odds ratio of 2.26 (both models are in Table A3 in the supplementary material). This surprising finding can be explained by the fact that extremely hostile and insulting Tweets are more likely to be instantly deleted by Twitter because they contravene the terms of service of the platform. As a result, extreme levels of hostility are underrepresented in our data. A closer inspection of Fig. 2 corroborates this reasoning, as it demonstrates fewer data points (i.e., lighter areas) at the upper end of each y-axis. Consequently, the estimated effects we report in this study are overly conservative.

Second, we estimated linear trends in the models above, but this may hide some complexity in the temporal dynamics. To account for this possibility, we employ a non-parametric modeling approach to plot trends in the before and after attack periods by case. In particular, we employ generalized additive models with integrated smoothness estimation using restricted marginal likelihood estimation. Fig 3 reveals that the pre-attack period, indicated by the blue lines, shows no distinct trends in either case. Following each attack, the heightened hostility level gradually diminishes, as marked by the red lines in the graph. This trend returns to pre-attack values, typically within a maximum timeframe of 10,000 min (about 7 days). However, in certain instances, such as the 2016 Belgium attack or the 2017 London Bridge attack, we observe a quicker return to pre-attack levels, indicating a more rapid normalization of hostility levels in these cases. Thus, while linear modelling is an approximation of trends, it appears to capture the underlying structure of our data sufficiently well.

Fig. 3
figure 3

Nonparametric modeling of trends by case. Note The Fig is analogous to Fig. 2, but the trends are estimated nonparametrically as generalized additive models with integrated smoothness estimation, separately for the before and after periods

Another major concern with Twitter lies in bots. While unambiguously identifying bots is notoriously difficult, users with a large number of posts have higher rates of bot-like behavior [22 (p. 4)]. To minimize the possibility that our results were mainly caused by bots, we re-ran the analysis but dropped the top 1% of active users in terms of Tweeting.Footnote 7 This removes 12,349 highly active users, leaving us with 1,189,935 individual users. Again, the results are highly similar to the ones reported in the main analysis. There is no trend in the before period (p = 0.766), a 9.9% points jump during the attacks, and a significant negative trend of -1.45 points per day in the time after the attacks (see Table A4 in the supplementary material).

Finally, we ran a couple of placebo tests to rule out the possibility that the rise in ethno-religious hostility is simply a matter of chance. As a first placebo, we only looked at the period before the attack, as we assumed that nothing relevant to our research question happened during this time. The first placebo is the time point that divides the first week in half. Put differently, we compared trends in the first and last 3.5 days and the change in the middle. As expected, we see a much smaller difference in hostility at this point, of only 1.42% points, and practically no trend in either the first or the second half of this period (the first model in Table A5 in the supplementary material). As a second placebo test, we used the full time frame and generated a treatment at a random time point. In this case, we again find a much smaller difference in hostility between both periods, with a placebo estimate of -1.26 points. We do observe a significant positive trend before and a negative trend in the after period (second model in Table A5). This is to be expected though, as the randomly generated placebo happened to be in the period after the attacks. Thus, the higher levels of hostility after attacks increase the slope of the trend before the random placebo, and the negative trend afterward is part of the after period we show in the main analysis. Together, both placebo attacks reinforce our confidence that the results we report above are causally related to the attacks.

Conclusion

Summary

Jihadist terrorism fuels online hate across cases and countries. We find higher levels of ethno-religious hostility after attacks, but this effect vanishes over time. These findings nicely align with Legewie [11], who used data from the European Social Survey to show that the negative effect of terrorism on immigration attitudes abates over time. In our case, the estimated time until returning to the baseline level is seven days. This also confirms Hopkins [10] and Turkoglu and Chadefaux [38], who both report that the effects of terror attacks are short-lived. We also find statistically significant and sizeable changes in Tweeting hostility within users. At first glance, this seems to somewhat contradict research arguing that attitudes remain relatively stable over time [17, 19]. However, this is not necessarily the case, as Kustov et al. [19] primarily argue about long-term changes in immigration attitudes, spanning several years. The present study, in contrast, focuses on short-term changes in expressing hostility on social media. We further find that changes within individuals only account for part of the overall effect. Thus, the overall pattern is shaped by a combination of hostility change within users and changes in the population composition of Tweeters.

Limitations

Firstly, it is unclear how well our findings generalize across social media platforms. This is particularly relevant for Twitter, where users are usually younger, wealthier, and better educated than other Internet users and especially more so than nonusers [64]. The lack of representativeness of Twitter users complicates inference to other populations.

Secondly, the fact that we used the historical version of the Academic Twitter API leads to the issue of deleted data. Twitter’s policy during our period of investigation included the removal of extreme hate speech. The fact that we find weaker effects for more extreme forms of hostility—that is, for Tweets that were 90% hostile vis-à-vis Tweets that were 75% hostile—corroborates this reasoning. As a consequence, the results we present in this study are overly conservative, underestimating the boost in hateful Tweets posted after an attack but then deleted. One might think this concerns earlier attacks more, as more time would have passed in which Tweets could have been deleted. However, the findings also indicate that neither the total level of hostility nor the attack effects are significantly lower for attacks that happened earlier. One explanation for this could be that most extreme hate speech is detected and deleted immediately. In this case, Tweets that have survived for a certain amount of time are likely to remain on the platform. In addition to the deletion of Tweets by Twitter, historic Tweets disappear if they are deleted by the author, or if the author deletes their account. However, it is less likely that this systematically relates to the results presented in this study.

A third limitation is that the classification of Tweets as hostile based on machine learning is something of a black box, due to the proprietary nature of the Perspective API. This is unfortunate, as science should aim for understanding and replicability. However, we also do not know the neural processes that lead to classification decisions in humans. From an applied perspective, the most important issue is that the algorithm performs well, which it does according to our validation.

Finally, it is hard to perfectly identify which users are bots, which means that parts of our data may have been generated by machines instead of humans. We tried to tackle this issue by removing highly active accounts as a robustness check. Moreover, bots — by definition — are programmed to write content on an automated basis (e.g. at a specific hour; see [22]). Given that the terror attacks are exogenous events, such automated posting should, at worst, bias the attack effect toward zero. Yet, the problem of automatic activities might be stronger for more recent attacks, as the number of bots operating on Twitter has increased over time [22]. However, we do not observe differences in trends by year in our data.

Discussion

In sum, our results show that major Jihadist terrorist attacks boost ethno-religious hostility in the digital socioscope Twitter and make individual users more hostile. There is a substantial rise in hostility in the general migration discourse on Twitter after the attacks. Given the importance of online hostility and hate speech for offline behavior, our findings have important implications for the social cohesion of modern multi-ethnic societies. Indeed, online hostility can have real-world consequences, shaping election outcomes [30] as well as violence against refugees [31]. Moreover, because the content of social media is not only influenced by but also influences the content of mass media [28, 29], online hostility may have a spillover effect on traditional and right-wing [65] news outlets. In turn, far-right violence can lead to increased online visibility and influence of right-wing extremists [66]. Finally, social media plays a crucial role as a source of political information for the younger generation. The rise of online ethno-religious hostility, thus, may have an especially pronounced impact on those who are in their impressionable years.

The rise of ethno-religious hostility is likely to become even stronger following the takeover of Twitter (now called X) by Elon Musk, who sees himself as a “free speech absolutist” and purchased the platform with the explicit goal of keeping more controversial content. With this new policy in place, online hatred is likely to become even more widespread — or, at least, will remain more visible. This will likely make the platform (even) more toxic after terrorist attacks. Unfortunately, the abolition of the free academic API by Elon Musk will be a great barrier to future research using Twitter or X data.