They say repetition is key to retention and in Disney/Pixar’s animated feature “Coco,” the song “Remember Me” is the tie that binds multiple generations in the shared love of music. It is central to the story about a young boy named Miguel who is pulled by the song from the land of the living to the land of the dead, gradually discovering the origins of the composition and awakening his own inner showmanship. Also part of the plotline are recollections of the distant past – hence, the song’s title — and of beloved long gone family members.

But having “Remember Me” act as an emotional centerpiece of the film posed creative challenges right from the start of production. Namely: how to pivot a tune to take on different meanings depending on the story’s context, setting or otherworldliness?

One hurdle they were able to traverse was in recruiting Oscar-winning “Frozen” songwriters Kristen Anderson-Lopez and Robert Lopez to pen the song, which is heard four times in the movie — first by the legendary Ernesto de la Cruz (Benjamin Bratt) in a crowd-pleasing mariachi arrangement; then by Hector (Gael Garcia Bernal) as a lullaby to his daughter; by lead character Miguel (Anthony Gonzalez) in an emotional reunion with his great-grandmother; and in the end-credits, where a pop version is delivered by R&B singer Miguel and Natalia Lafourcade.

Director Lee Unkrich had admired the Lopezes’ songs for some time, especially the Disney World “Finding Nemo” attraction based on the Pixar film he had co-directed. “I remember being blown away by it,” Unkrich tells Variety. “They were able to musically infuse emotion into parts of the story that we hadn’t quite nailed in the movie.”

So even before the opening of “Frozen” and the phenomenon of “Let It Go,” Unkrich brought the songwriters onto “Coco.” In its earliest stages, the director reveals, “we were kicking around the idea of doing a musical. As the story developed, it became a music-filled film but not a break-into-song musical. At that point they had already written ‘Remember Me.'”

Robert Lopez remembers the initial request: “‘Can you write a song that means one thing in one context and another thing in another?’ To us it was the difference between performing a song to call attention to yourself, to show off; and a song as a gift to someone you love. We wanted to write a song that could be interpreted both ways.”

They researched popular Mexican music from earlier in the 20th century “that would have been sung by [Mexican singers] Jorge Negrete or Pedro Infante at the time,” Robert adds. “It was really a wide variety, and there was a lot of American popular-song influence. So we decided to write a song in that bolero-ranchero style that also worked as a quiet ballad.”

Robert wrote a melody that Kristen says she immediately loved and, in developing a lyric, applied it to “something we personally were dealing with as a family: How do we stay connected when we are so far away?” says Kristen. (The couple lives in New York but travel to the West Coast often, leaving their children with caretakers). “I wrote that lyric from a very personal place …. and it seemed to work for what [the film] needed.

“That third time you hear it,” adds Kristen, “is really meaningful. It’s the power of music to bring people back to life, literally and figuratively. That was very affecting to us.”

The Lopezes worked on the arrangements with arranger-orchestrator Germaine Franco, who co-wrote five other songs in the film and whose expertise on Mexican musical idioms informs the entire score. Franco took the charts to Mexico City and recorded the music with some of the country’s top musicians for added musical authenticity.

“‘Remember Me’ works so well because it’s a really great melody and it’s flexible,” says Franco. “It’s interesting rhythmically. The melody leads you into the highs and the lows, so it can be small or big.”

It was Disney executive vice-president of music Tom MacDougall who convinced director Unkrich that one final use of the song was necessary, over the end titles. “I wanted a world-class singer, and Miguel is that, plus his father is Mexican,” MacDougall says. “Then [co-director] Adrian Molina asked if it could be a duet.” Mexican artist Natalia Lafourcade “felt like the right, youthful voice,” adds the executive. “And having her sing in Spanish further tied it to Mexico.”

When it was all over, MacDougall told the Lopezes: “This song is the culmination of the movie. You may not have as much time and care taken to marry a song to a visual ever again.”