Hologres, yol ayrıntısı ve yol ayrıştırma işlevlerini içeren bir dizi yol analizi işlevi sunar. Bu işlevler, yol hesaplama görevlerini verimli şekilde işleyerek yol ayrıntılarını hesaplar ve sonuçları ayrıştırır. Kaydedilen verileri kullanarak karmaşık yol bilgilerini anlamaya ve görselleştirmeye yardımcı olan bir Sankey diyagramı oluşturabilirsiniz. Bu konuda yol ayrıntısı ve yol ayrıştırma işlevlerinin nasıl kullanılacağı açıklanmaktadır.
Arka Plan
Yol analizi, kullanıcılar ürününüz veya özelliğinizle etkileşime geçtiğinde her oturumdaki kullanıcı yollarının dağılımını ve eylem sırasını kaydeder. Kullanıcı davranışına ilişkin sezgisel bir Sankey diyagramı üretir. Sankey diyagramı, kullanıcı akışındaki her bir ana düğümü ve bu düğümler arasındaki trafiği görüntüler; bu sayede detaylı iş analizi yapılabilir. Yol analizini kullanarak, ürününüzün her bir ana özelliğiyle olan kullanıcı etkileşimini net bir şekilde anlayabilirsiniz. Bu durum, operasyon ve ürün ekiplerinizin iş stratejilerini optimize etmesine ve ürünü geliştirmesine yardımcı olarak iş büyümesini destekler. Hologres, detaylı yol hesaplaması için bir yol ayrıntısı işlevi ve sonuç analizi için bir yol ayrıştırma işlevi destekler. Çıktı doğrudan Sankey diyagramı oluşturmak için kullanılabilir.
Yol analizi Sankey diyagramı arayüzünün üst kısmında bir time zone selector, bir time range selector, maximum number of nodes per layer ayarları ve bir Export düğmesi bulunur. Sankey diyagramı, başlangıç olayından (örneğin $AppStart) başlayarak sonraki kullanıcı eylemlerini ($AppEnd, AppPageview, Search, CheckIn ve AllPayments gibi) aşamalı olarak gösterir. Her düğüm, olay adı ve tetiklenme sayısı ile etiketlenir; düğümler arasındaki akışın genişliği ise trafik hacmini yansıtır.
Kullanım notları
Yol analizi işlevleri Hologres V2.2 ve sonraki sürümlerde kullanılabilir. Örneğiniz V2.1 veya önceki bir sürümse örneğinizi yükseltmek için Hologres teknik desteği ile iletişime geçin.
-
Yol analizi işlevlerini kullanmak için bir uzantı oluşturmanız gerekir. Uzantı varsayılan olarak public şemasına yüklenir ve diğer şemalara yüklenemez.
--Create the extension. CREATE extension flow_analysis;NotUzantı veritabanı düzeyindedir ve her veritabanı için yalnızca bir kez oluşturulmalıdır.
Yol ayrıntısı işlevleri
Yol ayrıntısı işlevi (path_analysis_detail)
path_analysis_detail işlevi, belirtilen olay verilerini analiz eder ve bunları ayrıntılı bir yol yapısı olarak sunar. Çıktı, tam yol dizisi, yoldaki düğümler arasındaki üst-alt ilişkileri ve her adımın süresi dahil olmak üzere kapsamlı bilgiler içeren serileştirilmiş bir dizidir.
-
Sözdizimi
path_analysis_detail( event, event_time, start_event, session_interval_sec, path_depth, path_offset, is_reverse, split_session_by_event) -
Parametreler
Parameter
Type
Description
event
text (data)
Analiz edilecek olay.
event_time
timestamp, timestamptz, bigint (data)
Her olayın zaman damgası.
start_event
text (literal)
Belirtilen başlangıç veya bitiş olayı.
session_interval_sec
bigint (literal)
Oturum aralığı (saniye cinsinden).
Bir oturumdaki ardışık olaylar arasındaki süre belirtilen oturum aralığını aşarsa sistem bunu iki oturuma böler. Örneğin, aralığı 30 saniye olarak ayarlarsanız ve iki olay arasındaki süre 30 saniyeden büyükse bu olaylar farklı oturumların parçası olarak kabul edilir.
path_depth
bigint (literal)
Belirtilen başlangıç veya bitiş olayından itibaren dizide alınacak olay sayısı.
path_offset
bigint (literal)
Başlangıç veya bitiş olayından olay sapması. 0 değeri sapma olmadığını belirtir.
Örneğin, a, b ve c olay serisinde a başlangıç olayıysa ve sapma 1 ise eşleşme b olayından başlar.
is_reverse
bool (literal)
Olay serisinin çıktı sırası. Geçerli değerler:
-
false: Bir başlangıç olayı belirtir. Olay serisi kronolojik sırayla döndürülür.
-
true: Bir bitiş olayı belirtir. Olay serisi ters kronolojik sırayla döndürülür.
split_session_by_event
bool (literal)
Oturum bölme yöntemi. Geçerli değerler:
-
true: Olay serisinde belirtilen başlangıç veya bitiş olayıyla karşılaşıldığında yeni bir oturum başlatılır.
-
false (Varsayılan): Oturumlar yalnızca
session_interval_secparametresinin değerine göre bölünür.Notsession_interval_sec-1 olarak ayarlanırsa oturumlar zamana göre değil olaya göre bölünür.
Örneğin, aynı oturum içinde
abcabc...abcgibi bir yol 10 kez tekrarlanıyorsa işlevin eşleşme mekanizması yalnızca tek bir dönüşümü kaydeder. Yolun her tekrarını bağımsız olarak hesaplamak amacıyla yeni bir oturum olarak ele almak isterseniz bu parametreyitrueolarak ayarlayabilirsiniz. Bu sayede her yeni işlem ayrı ayrı kaydedilir ve sayılır. -
-
Dönüş değeri
path_analysis_detail:
textveri türünde bir değer döndürür. Örnek:{"",\x01a\x01b<,\x01b\x01c<,""}.NotSonucu okumak için karşılık gelen bir yol ayrıştırma işlevi kullanmanız gerekir.
**pad_funnel işlevi**
pad_funnel işlevi, belirli bir olay kombinasyonu için alt yol bilgilerini alır.
-
Sözdizimi
pad_funnel(path_analysis_detail(), target_path) -
Parametreler
Parameter
Type
Description
path_analysis_detail()
text (data)path_analysis_detailişlevi tarafından döndürülen sonuç.
target_path
text (literal)
Belirtilen olay serisi. -
Dönüş değeri
pad_funnel: Bir
textdeğeri döndürür. Örnek:text []{"",\x01a\x01b<,\x01b\x01c<,""}.NotSonucu okumak için karşılık gelen bir yol ayrıştırma işlevi kullanmanız gerekir.
Yol ayrıştırma işlevleri
pad_full_path işlevi
pad_full_path işlevi, path_analysis_detail sonucunu üst yollara, alt yollara ve her adımın süresine ayrıştırır.
-
Sözdizimi
pad_full_path(path_analysis_detail()) -
Parametreler
path_analysis_detail():
path_analysis_detailişlevi tarafından döndürülen sonuç. -
Dönüş değeri
-
pad_full_pathişlevi aşağıdaki içeriği döndürür.pad_sub_path_left(unnested_pad_result) pad_sub_path_right(unnested_pad_result) pad_sub_index_left(unnested_pad_result) pad_sub_index_right(unnested_pad_result) pad_sub_cost(unnested_pad_result) pad_sub_session(unnested_pad_result) -
Aşağıdaki tabloda dönüş parametreleri açıklanmaktadır.
Function
Type
Description
pad_sub_path_left
text
Alt yolun başlangıç olayı.
pad_sub_path_right
text
Alt yolun bitiş olayı.
pad_sub_index_left
bigint
Oturumun tam yolu içindeki alt yolun başlangıç olayının indeksi.
pad_sub_index_right
bigint
Oturumun tam yolu içindeki alt yolun bitiş olayının indeksi.
pad_sub_cost
bigint
Alt yol için geçiş süresi (saniye cinsinden).
pad_sub_session
bigint
Alt yolun ait olduğu geçerli oturumun indeksi.
-
pad_session_path_array işlevi
pad_session_path_array işlevi, belirtilen oturum kimliğine ait olay serisini bir dizi olarak çıkarır.
-
Sözdizimi
pad_session_path_array(path_analysis_detail(), session_idx) -
Parametreler
path_analysis_detail():
path_analysis_detailişlevi tarafından döndürülen sonuç.session_idx: Belirtilen oturum indeksi.
-
Dönüş değeri
Dizi türünde veri döndürür.
Örnekler
Veri hazırlama
--Create the extension if it does not already exist.
CREATE extension flow_analysis;
--Prepare the data.
CREATE TABLE path_demo(
uid text,
event text,
event_time timestamptz
);
INSERT INTO path_demo VALUES
('1','Register','2023-11-24 16:01:23+08'),
('1','Log on','2023-11-24 16:02:10+08'),
('1','Browse','2023-11-24 16:02:15+08'),
('1','View live streams','2023-11-24 16:03:10+08'),
('1','Browse','2023-11-24 16:03:15+08'),
('1','Add to favorites','2023-11-24 16:04:20+08'),
('1','Browse','2023-11-24 16:07:21+08'),
('1','Purchase','2023-11-24 16:08:23+08'),
('1','Exit','2023-11-24 16:09:05+08'),
('2','Log on','2023-11-24 16:10:23+08'),
('2','Purchase','2023-11-24 16:12:23+08'),
('3','Log on','2023-11-24 16:02:23+08'),
('3','Browse','2023-11-24 16:02:23+08'),
('3','Add to favorites','2023-11-24 16:03:53+08'),
('3','View live streams','2023-11-24 16:04:53+08'),
('4','Log on','2023-11-24 16:02:23+08'),
('4','Browse','2023-11-24 16:03:53+08'),
('4','Purchase','2023-11-24 16:04:23+08'),
('4','View live streams','2023-11-24 16:05:53+08'),
('4','Cancel the order','2023-11-24 16:06:53+08');
Örnek 1: Tüm olay yollarını kaydetme
-
Oturumları zamana göre bölün.
--Split by time: Specify 'Log on' as the start event, set the session interval to 180 s, and set the matching sequence length to 7. Then, use the pad_full_path function to decode the results. SELECT uid, pad_full_path(path_analysis_detail(event, event_time, 'Log on', 180, 7, 0, false)) AS ret FROM path_demo GROUP BY uid;Aşağıdaki sonuç döndürülür.
uid | ret -----+--------------------------------------------------- 3 | {Log on->Add to favorites->View live streams} 4 | {Log on->Browse->Purchase->View live streams->Cancel the order} 1 | {Log on->Browse->View live streams->Browse->Add to favorites} 2 | {Log on->Purchase} (4 rows) -
Oturumları zamana ve olaya göre bölün.
--Split by time and event: Specify 'Browse' as the start event, set the interval to 180 s, and set the sequence length to 7. Then, use the pad_full_path function to decode the results. SELECT uid, pad_full_path(path_analysis_detail(event, event_time, 'Browse', 180, 7, 0, false,TRUE)) AS ret FROM path_demo GROUP BY uid;Aşağıdaki sonuç döndürülür.
uid | ret -----+----------------------------------------------------------- 1 | {Browse->View live streams,Browse->Add to favorites,Browse->Purchase->Exit} 2 | {} 4 | {Browse->Purchase->View live streams->Cancel the order} 3 | {Browse->Log on->Add to favorites->View live streams}
Örnek 2: Yol sonucunu genişletme
--Expand the paths.
SELECT uid, unnest(pad_full_path(path_analysis_detail(event, event_time, 'Log on', 180, 7, 0, false))) AS ret FROM path_demo GROUP BY uid;
UNNEST işlevi hakkında daha fazla bilgi için bkz. UNNEST yan tümcesi.
Aşağıdaki sonuç döndürülür.
uid | ret
-----+-------------------------------------------------
3 | Log on->Add to favorites->View live streams
1 | Log on->Browse->View live streams->Browse->Add to favorites
2 | Log on->Purchase
4 | Log on->Browse->Purchase->View live streams->Cancel the order
(4 rows)
Örnek 3: Alt yol ayrıntılarını genişletme
--Expand the subpaths.
SELECT
uid,
pad_sub_session (ret) AS session_id,
pad_sub_path_left (ret) AS sub_path_left,
pad_sub_path_right (ret) AS sub_path_right,
pad_sub_index_left (ret) AS sub_index_left,
pad_sub_index_right (ret) AS sub_index_right,
pad_sub_cost (ret) AS sub_cost
FROM (
SELECT
uid,
unnest( path_analysis_detail (event, event_time, 'Log on', 180, 7, 0, FALSE)) AS ret
FROM
path_demo
GROUP BY
uid) a ;
Aşağıdaki sonuç döndürülür.
uid | session_id | sub_path_left | sub_path_right | sub_index_left | sub_index_right | sub_cost
-----+------------+---------------+----------------+----------------+-----------------+----------
1 | 0 | | Log on | -1 | 0 | 0
1 | 0 | Log on | Browse | 0 | 1 | 5
1 | 0 | Browse | View live streams | 1 | 2 | 55
1 | 0 | View live streams | Browse | 2 | 3 | 5
1 | 0 | Browse | Add to favorites | 3 | 4 | 65
2 | 0 | | Log on | -1 | 0 | 0
2 | 0 | Log on | Purchase | 0 | 1 | 120
3 | 0 | | Log on | -1 | 0 | 0
3 | 0 | Log on | Add to favorites | 0 | 1 | 90
3 | 0 | Add to favorites | View live streams | 1 | 2 | 60
4 | 0 | | Log on | -1 | 0 | 0
4 | 0 | Log on | Browse | 0 | 1 | 90
4 | 0 | Browse | Purchase | 1 | 2 | 30
4 | 0 | Purchase | View live streams | 2 | 3 | 90
4 | 0 | View live streams | Cancel the order | 3 | 4 | 60
(15 rows)
Örnek 4: Oturum olay serisini alma
SELECT
uid,
pad_session_path_array (path_analysis_detail (event, event_time, 'Log on', 180, 7, 0,FALSE), 0) AS ret
FROM
path_demo
GROUP BY
uid;
Aşağıdaki sonuç döndürülür.
uid | ret
-----+-----------------------------------------------
1 | {Log on,Browse,View live streams,Browse,Add to favorites}
2 | {Log on,Purchase}
3 | {Log on,Add to favorites,View live streams}
4 | {Log on,Browse,Purchase,View live streams,Cancel the order}
(4 rows)
Örnek 5: Alt yol PV ve UV değerlerini hesaplama
--Calculate the page view (PV) and unique visitor (UV) for each subpath without deduplication. If you need to deduplicate the results, you can perform deduplication on the uid.
SELECT
sub_index,
sub_path_left,
sub_path_right,
count(uid)
FROM (
SELECT
uid,
pad_sub_path_left (ret) AS sub_path_left,
pad_sub_path_right (ret) AS sub_path_right,
pad_sub_index_right (ret) AS sub_index
FROM (
SELECT
uid,
unnest(path_analysis_detail (event, event_time, 'Log on', 180, 7, 0, FALSE)) AS ret
FROM
path_demo
GROUP BY
uid) a) a
GROUP BY
sub_index,
sub_path_left,
sub_path_right
ORDER BY
sub_index,
sub_path_left,
sub_path_right;
Aşağıdaki sonuç döndürülür.
sub_index | sub_path_left | sub_path_right | count
-----------+---------------+----------------+-------
0 | | Log on | 4
1 | Log on | Add to favorites | 1
1 | Log on | Browse | 2
1 | Log on | Purchase | 1
2 | Add to favorites | View live streams | 1
2 | Browse | View live streams | 1
2 | Browse | Purchase | 1
3 | View live streams | Browse | 1
3 | Purchase | View live streams | 1
4 | Browse | Add to favorites | 1
4 | View live streams | Cancel the order | 1
(11 rows)
Örnek 6: Ortalama alt yol süresini hesaplama
--Calculate the average duration for each subpath.
SELECT
sub_path_left,
sub_path_right,
avg(sub_cost)
FROM (
SELECT
uid,
pad_sub_path_left (ret) AS sub_path_left,
pad_sub_path_right (ret) AS sub_path_right,
pad_sub_cost (ret) AS sub_cost
FROM (
SELECT
uid,
unnest(path_analysis_detail (event, event_time, 'Log on', 180, 7, 0, FALSE)) AS ret
FROM
path_demo
GROUP BY
uid) a) a
GROUP BY
sub_path_left,
sub_path_right
ORDER BY
sub_path_left,
sub_path_right;
Aşağıdaki sonuç döndürülür.
sub_path_left | sub_path_right | avg
---------------+----------------+------------
Add to favorites | View live streams | 60.000000
Browse | Add to favorites | 65.000000
Browse | View live streams | 55.000000
Browse | Purchase | 30.000000
Log on | Add to favorites | 90.000000
Log on | Browse | 47.500000
Log on | Purchase | 120.000000
View live streams | Cancel the order | 60.000000
View live streams | Browse | 5.000000
Purchase | View live streams | 90.000000
| Log on | 0.000000
(11 rows)
Örnek 7: Oturum yollarını alt yol ayrıntılarıyla ilişkilendirme
--Associate session paths with subpaths.
select
uid,
pad_sub_session(item) as session_id,
full_path [pad_sub_session(item)+1] as full_path,
pad_sub_path_left(item) as sub_path_left,
pad_sub_path_right(item) as sub_path_right,
pad_sub_index_right(item) as sub_idx,
pad_sub_cost(item) as sub_cost
from
(
select
uid,
unnest(ret) as item,
pad_full_path(ret) as full_path
from
(
select
uid,
path_analysis_detail(event, event_time, 'Log on', 180, 7, 0, false) as ret
from
path_demo
group by
uid
) a
) a;
Aşağıdaki sonuç döndürülür.
uid | session_id | full_path | sub_path_left | sub_path_right | sub_idx | sub_cost
-----+------------+-------------------------------------------------+---------------+----------------+---------+----------
3 | 0 | Log on->Add to favorites->View live streams | | Log on | 0 | 0
3 | 0 | Log on->Add to favorites->View live streams | Log on | Add to favorites | 1 | 90
3 | 0 | Log on->Add to favorites->View live streams | Add to favorites | View live streams | 2 | 60
1 | 0 | Log on->Browse->View live streams->Browse->Add to favorites | | Log on | 0 | 0
1 | 0 | Log on->Browse->View live streams->Browse->Add to favorites | Log on | Browse | 1 | 5
1 | 0 | Log on->Browse->View live streams->Browse->Add to favorites | Browse | View live streams | 2 | 55
1 | 0 | Log on->Browse->View live streams->Browse->Add to favorites | View live streams | Browse | 3 | 5
1 | 0 | Log on->Browse->View live streams->Browse->Add to favorites | Browse | Add to favorites | 4 | 65
2 | 0 | Log on->Purchase | | Log on | 0 | 0
2 | 0 | Log on->Purchase | Log on | Purchase | 1 | 120
4 | 0 | Log on->Browse->Purchase->View live streams->Cancel the order | | Log on | 0 | 0
4 | 0 | Log on->Browse->Purchase->View live streams->Cancel the order | Log on | Browse | 1 | 90
4 | 0 | Log on->Browse->Purchase->View live streams->Cancel the order | Browse | Purchase | 2 | 30
4 | 0 | Log on->Browse->Purchase->View live streams->Cancel the order | Purchase | View live streams | 3 | 90
4 | 0 | Log on->Browse->Purchase->View live streams->Cancel the order | View live streams | Cancel the order | 4 | 60
(15 rows)
Örnek 8: Kısmi yol ayrıntılarını görüntüleme
--View conversion details for a specific path ('Log on' to 'Purchase') using the pad_funnel function.
SELECT uid, pad_full_path(pad_funnel(path_analysis_detail(event, event_time, 'Log on', 180, 7, 0, false), array['Log on', 'Purchase'])) AS ret FROM path_demo GROUP BY uid;
Aşağıdaki sonuç döndürülür.
uid | ret
-----+------------------
3 | {Log on}
4 | {Log on->Purchase}
1 | {Log on}
2 | {Log on->Purchase}
(4 rows)