Just make sure to hold onto happiness when/whenever you get the chance.
Should I use when or whenever in this case? When should I use the former and when should I use the latter?
English Language Learners Stack Exchange is a question and answer site for speakers of other languages learning English. It only takes a minute to sign up.Sign up to join this community
Both are okay, but they might or might not mean something different depending on how you look at it.
Generally, "Whenever X, Y" means that X happened/happens/is supposed to happen many times, and each and every time Y also happens (or in this case, you're told to make it happen). So your sentence would read as a general rule - "you'll have many chances to hold onto happiness in your life, and each time that happens, make sure to do so".
"When X, Y" can mean a single occurence - X happened/will happen, and Y happened/will happen at the same time. So you'd rather say "...when you get the chance" if there's a particular chance to be had - for example, you know your friend is getting a new job, and he's being anxious for it, so you're telling him to hold onto that once he gets the chance (and that job). Compare "When you get that job, you'll be out of trouble" vs (technically grammatical, but making no sense). !"Whenever you get that job, you'll be out of trouble"
Now, what @Man_From_India said also holds - if the context or grammar already estabilishes that you're talking about a repeating occurence, you can use "when" in place of "whenever". For example, "Check your locks when you leave your house" can be placed in a health and safety guide, and it would mean the same as "...whenever you leave...".