Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When i enable the download tracking, the downloads are not logged to analytics.
After some debugging i discovered that the click event ($(document.body).click(function(event) {) is not called, when clicking on a link.
Tested this in firefox.
Comments
Comment #1
hass CreditAttribution: hass commentedYou may have disabled download tracking. Otherwise we need an example site with latest version installed where you think it's not working.
Comment #2
hass CreditAttribution: hass commentedComment #3
hass CreditAttribution: hass commentedComment #4
nils.destoop CreditAttribution: nils.destoop commentedDownload tracking is enabled.
If i changed code to:
Then everything is working.
This means the listener on links is working, but a listener on document.body is not working (if a link was clicked).
Comment #5
hass CreditAttribution: hass commentedThe code worked for past 2 or more years.
Comment #6
hass CreditAttribution: hass commentedThis issue is reproducible under Firefox, Chrome works. I can confirm that the tracking pixel is not send to Google in Firebug. The reason seems not the JavaScript itself. With an console.log() I see that all code runs correctly. Only the
_trackEvent
is not executed or at least it has not enough time to load before an PDF is opened in the same window.Looks like a duplicate of #1580144: Links not tracked in some browsers as jquery click event exits before tracking code finishes.
Comment #7
hass CreditAttribution: hass commentedTested Firefox with TXT and PDF (both are not tracked). Tested with MSI download (works). It looks like, if the browser is able to open the download itself internally - tracking fails. If a download/save dialog appears - tracking works.
Your change to A element is invalid and will cause slow unbinding issues, see #336924: Massive page rendering slowdown with many links. Additional it also does not help anything here.
Comment #8
hass CreditAttribution: hass commentedChrome seems to have the same issues.
Comment #9
hass CreditAttribution: hass commented#1580144: Links not tracked in some browsers as jquery click event exits before tracking code finishes