Skip to main content

Hello !


I’ve created a sticky bar in unbounce.

In this sticky bar, i built a 24 hours countdown from a static timestamp.

I have a dynamic timestamp inside a variable built in GTM that i would like to use in my script.

But i haven’t figure out how to manipulate external variable in Unbounce.


<script>

var startDemo = google_tag_managera'GTM-xxxxx'].dataLayer.get('gtm.start');

startDemo = startDemo - 3600000;
const hour = document.querySelector("#lp-pom-text-111");
const min = document.querySelector("#lp-pom-text-112");
const sec = document.querySelector("#lp-pom-text-113");
hour.textContent = 'xx'
min.textContent = 'xx'
sec.textContent = 'xx'

const userSubscriptionDate = new Date(startDemo);
userSubscriptionDate.setDate(userSubscriptionDate.getDate() + 1)
window.setInterval(()=> {
const now = new Date()
var diff = Math.floor(userSubscriptionDate - now);

if(diff >= 0) {
const test = new Date(diff)
hour.textContent = test.getHours().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
})
min.textContent = test.getMinutes().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
})
sec.textContent = test.getSeconds().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
})
}
else {
hour.textContent = '00'
min.textContent = '00'
sec.textContent = '00'
}
}, 1000)


</script>

Can anyone help me please ? 😀

Hello again ! No one got an idea on how to do this ?


Reply