Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve detection of sources #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tinybird/pipes/analytics_hits.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SQL >
JSONExtractString(payload, 'referrer') as referrer,
JSONExtractString(payload, 'pathname') as pathname,
JSONExtractString(payload, 'href') as href,
domainWithoutWWW(href) as current_domain,
lower(JSONExtractString(payload, 'user-agent')) as user_agent
FROM analytics_events
where action = 'page_hit'
Expand All @@ -33,6 +34,7 @@ SQL >
referrer,
pathname,
href,
current_domain,
case
when match(user_agent, 'wget|ahrefsbot|curl|urllib|bitdiscovery|\+https://|googlebot')
then 'bot'
Expand Down
3 changes: 1 addition & 2 deletions tinybird/pipes/analytics_sources.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ DESCRIPTION >
Aggregate by referral and calculate session and hits

SQL >
WITH (SELECT domainWithoutWWW(href) FROM analytics_hits LIMIT 1) AS currenct_domain
SELECT
toDate(timestamp) AS date,
device,
Expand All @@ -13,7 +12,7 @@ SQL >
uniqState(session_id) AS visits,
countState() AS hits
FROM analytics_hits
WHERE domainWithoutWWW(referrer) != currenct_domain
WHERE domainWithoutWWW(referrer) != current_domain
GROUP BY date, device, browser, location, referrer

TYPE MATERIALIZED
Expand Down