Katy Perry went for a joy ride in Hawaii and came back with a song that should have Harley-Davidson dancing.

Last month, Ms. Perry released “Harleys in Hawaii,” a song inspired by a tropical idyll with her fiancé, the actor Orlando Bloom. Within two weeks, it had been streamed 20 million times on Spotify, and the accompanying music video — which features the pop star as both a rider and a passenger on Harley bikes — had been watched over 12 million times.

Many brands now spend as much on product placement with social media influencers as they do on advertising. Ms. Perry is a heavyweight on social media, with over 100 million followers on Twitter and 80 million on Instagram. But all Harley-Davidson did in exchange for the enormous exposure to her fan base was provide motorcycles for the video.

While Ms. Perry may not strike you as a typical Harley customer — spoiler alert: she’s not — the company has long acknowledged that it must replace its aging male customer base; younger riders in general, and women in particular, are a major marketing focus. Harley had been banking on a new electric bike, the LiveWire, but it was recently forced to halt production to address a charging issue.