File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,9 @@ def track_file_download():
72
72
client_id = request .cookies .get ("_ga" )
73
73
74
74
path = request .path
75
- file_name , file_extension = os .path .splitext (path )
75
+ last_slash_index = path .rfind ("/" )
76
+ file_dir = path [:last_slash_index ]
77
+ page_location = f"{ request .url_root } { file_dir [1 :]} "
76
78
77
79
url = f"{ ga_url } ?measurement_id={ ga_id } &api_secret={ api_secret } "
78
80
payload = {
@@ -82,9 +84,11 @@ def track_file_download():
82
84
{
83
85
"name" : "file_download" ,
84
86
"params" : {
85
- "file_extension" : file_extension . replace ("." , "" ) ,
86
- "file_name" : file_name ,
87
+ "file_extension" : path . split ("." )[ - 1 ] ,
88
+ "file_name" : path ,
87
89
"link_url" : request .url ,
90
+ "page_location" : page_location ,
91
+ "page_referrer" : request .referrer ,
88
92
},
89
93
}
90
94
],
You can’t perform that action at this time.
0 commit comments