“Don’t talk about religion or politics on social media,” I tell my clients. “You’re going to alienate at least half the population with your views, and what do you gain? Just keep it to yourself.” It’s been my standard line for as long as I’ve been doing this. But lately, I’ve had to reevaluate that advice.

In an age of increasing social and political polarization, more and more companies are taking a stand for something they believe in. J.C. Penney hired openly gay spokeswoman Ellen DeGeneres and released both Mother’s Day and Father’s Day ads depicting same-sex parents. More recently, Oreo posted a picture of a rainbow-colored cookie on its Facebook page, with the caption, “Proudly support love!”

Even a few years ago, such overt acts of support for gay rights would have been unthinkable for mainstream brands. But since 1996, support for gay marriage has nearly doubled, with a slight majority of Americans now favoring legalizing gay marriage. Even more than that, when we really crunch the numbers, we see that support for gay marriage is highest among those 18-29. In other words, the most coveted advertising demographic, the one that makes retailers and brands salivate, is decisively in favor of gay marriage–and more so all the time. And you can bet your bottom dollar that J.C. Penney and Kraft Foods (Oreo’s parent company) saw the same research before they released their marketing materials.

That’s not to say there hasn’t been blow back to both campaigns–Oreo’s Facebook page has plenty of comments from fans unhappy with the move, while the Million Moms campaign has an active boycott campaign in place against J.C. Penney. However, both companies have refused to budge in their stances, both issuing statements affirming their messaging.

So was this a smart move? While we don’t have access to their sales figures, we can at least get a glimpse at public opinion surrounding the moves. In 2012 we used Social Mention to see that positive sentiment surrounding Oreos is six times more positive than negative. For J.C. Penney, the equation is a little more even, with nearly even positive and negative sentiment, but J.C. Penney is also undergoing a leadership transition and a major strategy realignment after two catastrophic quarters. A quick (and decidedly non-scientific) Google search for “Boycott J.C. Penney” yields 202,000 hits, while “support J.C. Penney” yields 24 million; similar searches for Oreo offer 427,000 hits and 9.75 million hits, respectively.

Unfortunately, Social Mention no longer exists.  Today we would suggest you consider BrandMentions.com for a detailed analysis of your online brand image.

What’s the bottom line? What does this mean for your business? Is it okay to start discussing controversial subjects as a part of your marketing strategy? Well, maybe, but before you do, here are some things to consider:

1. Know your audience. Both Oreo and J.C. Penney are targeting a young demographic more likely than not to share the company’s stance on gay rights. If your target does not share the same beliefs, it may not be to your business’ advantage to make it a part of your marketing.

2. Keep it on-brand. This point is twofold. First, make sure the piece fits in with your overall marketing strategy. For instance, the same-sex couples in J.C. Penney’s ads were included in a regular ad spread, in the same style as the heterosexual families around them. This wasn’t out of character or out of the blue–it was an evolution of an existing strategy. Second, make sure your company is ready to walk the walk with the issue. Both Kraft Foods and J.C. Penney offer domestic partnership benefits and have made commitments to diversity core parts of their brand. Without those internal structures in place, the gestures would have rung as hollow and hypocritical.

3. Stand your ground. Both brands refused to back down in the face of a challenge from vocal opposition groups. Which is the best possible move. By backing down, they would have angered both sides of the issue–one side for running the ads in the first place, the other for refusing to stand up for what they believed in. If you’re going to make political statements a part of your marketing, go all in. Be prepared with a calm, measured response to controversy, and do not back pedal.

While I would still recommend that most businesses keep politics and commerce separate, these two brands show that you can win big by taking a calculated risk.