Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Create a data element containing scroll height of a popup

Avatar

Avatar
Validate 10
Level 3
philipk92120636
Level 3

Likes

13 likes

Total Posts

83 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Contributor
Give Back 3
Give Back
View profile

Avatar
Validate 10
Level 3
philipk92120636
Level 3

Likes

13 likes

Total Posts

83 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Contributor
Give Back 3
Give Back
View profile
philipk92120636
Level 3

06-01-2020

Hi all!

 

I want to create a data element that saves the distance a customer scrolls within a popup. I can return the value I'm after in the browser console using the following:

 

// Full height of div including scroll
var totalHeight = $("#myDialogContent")[0].scrollHeight;

// Initial height of div that needs to be subtracted
var initialHeight = $("#myDialogContent")[0].clientHeight;

// Actual element height value
var height = totalHeight - initialHeight;

// Scroll depth
var scroll = $("#myDialogContent").scrollTop();

var scrollPercentage = (scroll/height) * 100;

var rounded = Math.round(scrollPercentage);

return rounded;

 

This is the code I've used in the data element. However, when I try to return the value of the data element in the browser I get undefined each time.

 

Any help would be greatly appreciated. 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
Level 3
philipk92120636
Level 3

Likes

13 likes

Total Posts

83 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Contributor
Give Back 3
Give Back
View profile

Avatar
Validate 10
Level 3
philipk92120636
Level 3

Likes

13 likes

Total Posts

83 posts

Correct Reply

8 solutions
Top badges earned
Validate 10
Validate 1
Contributor
Give Back 3
Give Back
View profile
philipk92120636
Level 3

08-01-2020

This worked when I added it into a rule. I don't know why it didn't return through the console but I created a dummy data element change rule referencing the data element created using the above code and it worked as required.

Answers (1)

Answers (1)

Avatar

Avatar
Shape 1
Level 3
franzli
Level 3

Likes

28 likes

Total Posts

26 posts

Correct Reply

13 solutions
Top badges earned
Shape 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Shape 1
Level 3
franzli
Level 3

Likes

28 likes

Total Posts

26 posts

Correct Reply

13 solutions
Top badges earned
Shape 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
franzli
Level 3

06-01-2020

Might need some more context here. What kind of popup is it? Is it a whole new window popup? If so, you will need to make sure Launch is implemented on it as well.