Skip to content

Commit

Permalink
Fix: JavaScript error when element ID not set correctly in scroll tra…
Browse files Browse the repository at this point in the history
…cking
  • Loading branch information
duracelltomi committed Mar 12, 2024
1 parent 4baf4fc commit 6ed1bd1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/js/analytics-talk-content-tracking.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion js/analytics-talk-content-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ if ( "undefined" == typeof console ) {

// If user has hit the bottom of the content send an event
//if ( bottom >= $( '#' + gtm4wp_scrollerscript_contentelementid ).scrollTop() + $( '#' + gtm4wp_scrollerscript_contentelementid ).innerHeight() && !endContent ) {
if ( bottom >= document.querySelector('#' + gtm4wp_scrollerscript_contentelementid).scrollTop + document.querySelector('#' + gtm4wp_scrollerscript_contentelementid ).clientHeight && !endContent ) {
const scroll_top = document.querySelector('#' + gtm4wp_scrollerscript_contentelementid)?.scrollTop || 0;
const client_height = document.querySelector('#' + gtm4wp_scrollerscript_contentelementid )?.clientHeight || 0;
if ( bottom >= scroll_top + client_height && !endContent ) {

const currentTime = new Date();
const contentScrollEnd = currentTime.getTime();
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ to report micro conversions and/or to serve ads only to visitors who spend more

Fix: do not load GTM container when OFF and console.log OFF. Thanks [morvy](https://github.com/morvy)
Fix: reverted a change where item_id in ecommerce data layer was converted to numeric type when the value was a numeric value. It will be kept as a string to preserve compatibility with other integrations.
Fix: JavaScript error when element ID not set correctly in scroll tracking

= 1.20 =

Expand Down

0 comments on commit 6ed1bd1

Please sign in to comment.