I have some code which calls a function like this :
function trackPDFSEClicks(){
ahoy.track("Viewed Job Spec", {title: "Viewed Software Engineer Job Spec"});
window.location.href = "/Software Engineer.pdf";
}
However because this track call is asynchronous - sometimes it doesn't complete before the PDF has loaded - and therefore the event is not tracked.
I do not necessarily want to have to go and handle this tracking in the controller as it would be far simpler for me to use this method if possible - so is there any way I can force this ahoy.track call to be run synchronously?
经过呼吸暂停的见解,我决定只在控制器中为我的每个可下载链接创建一个动作-并将ahoy的rails API与rails send_file
方法结合使用-这给了我期望的行为。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.