CMS Development

julieta1
Participant

keeping the subscription types unchecked by default

SOLVE

I'm trying to set up the unsubscribe page in a way that the subscription types are unchecked by default. Currently all subscribe types are checked by default when "manage preferences" is clicked in the email footers. This makes it too easy to unsubscribe to every email type without reading the descriptions for each type, and then not get important communication from us about their product.

 

Has anyone tried to do this before? I'm not very savvy in javascript but i can potentially work off of something similar that has already been built for a similar purpose. 

0 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

keeping the subscription types unchecked by default

SOLVE

I would add it to the template HTML in a script tag like this. The window.onload event is fired when the whole page has loaded. You want to make sure the checkboxes are present in the DOM before doing anything to them, otherwise the checkboxes variable will return null.

 

<script>
  window.onload = (event) => {
    var checkboxes = document.querySelectorAll('.fakelabel input[type="checkbox"]');
    checkboxes.forEach((i) => {
      i.checked = false;
    });
  };
</script>

 

 

View solution in original post

6 Replies 6
piersg
Solution
Key Advisor

keeping the subscription types unchecked by default

SOLVE

I would add it to the template HTML in a script tag like this. The window.onload event is fired when the whole page has loaded. You want to make sure the checkboxes are present in the DOM before doing anything to them, otherwise the checkboxes variable will return null.

 

<script>
  window.onload = (event) => {
    var checkboxes = document.querySelectorAll('.fakelabel input[type="checkbox"]');
    checkboxes.forEach((i) => {
      i.checked = false;
    });
  };
</script>

 

 

julieta1
Participant

keeping the subscription types unchecked by default

SOLVE

Thanks so much for your help!! Really appreciate it.

dennisedson
HubSpot Product Team
HubSpot Product Team

keeping the subscription types unchecked by default

SOLVE

We'll keep @piersg around the community for a bit longer 😉

piersg
Key Advisor

keeping the subscription types unchecked by default

SOLVE

Hi @julieta1, this is intended behaviour in Hubspot: when you go to manage preferences from an email, your current subscriptions are automatically selected for you. You're seeing all of them selected because you are suscribed to all of your own types. I would advise against changing this user experience.

 

That said, if you really want to change this, this script should work

 

var checkboxes = document.querySelectorAll('.fakelabel input[type="checkbox"]');

checkboxes.forEach((i) => {
    i.checked = false;
});

 

 

julieta1
Participant

keeping the subscription types unchecked by default

SOLVE

Thank you @dennisedson and @piersg !

 

I created a new javascript file and added the script above in as-is. I then linked it to the subscription page template, but it's not working on my end. Is there anything I missed?

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

keeping the subscription types unchecked by default

SOLVE

Hey @julieta1 

There is this guy, we call him @piersg around these parts.  And I bet he has something to say on this topic.

0 Upvotes