13

Are there any pages/dashboards showing cross-site statistics indicating new enrollments, how many users become active on multiple sites, perhaps broken down to show the first website that new users joined?

For example, I first joined InfoSec SE and then got hooked to the QA format and joined several other SE sites.

2
  • You can check if one of my answers on similar posts like this, or this, or this will answer your question
    – rene
    Jul 11, 2016 at 19:32
  • 4
    Considering the size, if I had to guess, SO would be the gateway site... wasn't mine... but it's probably a safe guess.
    – Catija StaffMod
    Jul 11, 2016 at 20:12

1 Answer 1

15

I have created an query to answer the largest part of your question. The column labeled 1 will answer your question, that is the gateway drug site. At the end I explain a bit how this query works.

-- result table, don't rename and keep the site column
create table #results ( site nvarchar(250)
                       , uid int
                       , creationdate datetime
                       , aid int);

create index #idx_results_aid on #results (aid asc);

declare @sql nvarchar(max) = ''   -- holds build up sql string

-- build one biq union sql, for each db
select @sql = @sql 
+ iif( len(@sql) > 1 
     , 'union'
     , 'insert into #results'
) +
-- here goes the per site query, fully qualify the database objects
N'
select ''' + name + '''
     , id
     , creationdate
     , accountid
from ' + quotename(name) + '.dbo.users u 
where accountid is not null -- http://chat.meta.stackexchange.com/transcript/message/5222422#5222422
and accountid > 0 -- dont want community in there
'
from sys.databases
where database_id > 5
and (name not like '%.Meta' or name = 'StackExchange.Meta')
-- and not name = 'stackoverflow'

--print @sql

-- execute it
exec (@sql)

-- remove accounts that only participate on one site
delete from #results 
where aid in (
select aid 
from #results
group by aid
having count(*) = 1) 

-- show results
select site
     , [1]
     , [2]
     , [3]
     , [4]
     , [5]
     , [6]
     , [7]
     , [8]
     , [9]
     , [10]
from
(
 select site
   , rnk
   , count(*) as [usrcnt]
from (
select site
     , rank() over (partition by aid order by creationdate) as rnk
     -- rest of columns
     --, creationdate
     , aid
from #results
) as innerdata
group by site, rnk
) as outerdata
pivot (
  max(usrcnt)
  for rnk in ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10])
  ) as pivotdata
order by 2 desc

drop table #results

When run today the result will look like this, although you might want to read the explanation first:

pivot table of sites and site rank

What you see in the table is per site, the number of users that have accounts on multiple sites. The 1 column holds the number of users with that site as their first site, the 2 column the number of users that have that site as their second site etc.

Query explanation

The query starts with filling a #results temporary table with all the users from all databases, taking their id, creationdate, and accountid. The accountid is used to link each site user. The #results table is populated by executing an massive SQL union statement.

The #results table then holds:

site          | userid | creationdate | aid
--------------------------------------------
Stackoverflow |    12  | 2009-01-01   | 4
ServerFault   |    18  | 2010-03-03   | 4
SuperUser     |    19  | 2011-05-05   | 4
Stackoverflow |    22  | 2010-02-01   | 5
ServerFault   |    26  | 2011-04-04   | 5
SuperUser     |    28  | 2012-07-10   | 5
Stackoverflow |    38  | 2009-12-12   | 8

This example shows 3 accounts. The next step deletes all rows that only have one site (so in above example, the row with aid = 8 will be removed).

For each account the rank for each site is determined based on the creationdate.

site          | userid | rank | creationdate | aid
--------------------------------------------
Stackoverflow |    12  |  1   | 2009-01-01   | 4
ServerFault   |    18  |  2   | 2010-03-03   | 4
SuperUser     |    19  |  3   | 2011-05-05   | 4
Stackoverflow |    22  |  1   | 2010-02-01   | 5
ServerFault   |    26  |  2   | 2011-04-04   | 5
SuperUser     |    28  |  3   | 2012-07-10   | 5

Once that is done we can count the number of rows per site and rank to project our final result.

3
  • 1
    This agrees with my experience, it was StackOverflow for me :)
    – Josh B.
    Sep 1, 2016 at 15:11
  • Very interesting.I didn't actually discover SO or SU until long after I was on Sec.SE, but this gives a good indication how most people get into SE.
    – Rory Alsop
    Sep 1, 2016 at 16:27
  • In other words, "hard" (serious/work) sites lead people to "soft" sites. Makes sense.
    – luchonacho
    Oct 20, 2021 at 21:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .