Joel Gottfried’s relatives never know what to get him for his birthday.

That changed a few years ago, when Gottfried began researching his family tree. He started with his father’s parents — Jews who fled hardship and persecution in Europe — and managed to document, in minute detail, their arrival at Ellis Island. He loved it.

So when Gottfried’s 69th birthday rolled around in March 2018, his sister Debbie Heller at last had the perfect gift for her big brother. She ordered both of them an at-home genetic test, 23AndMe, so they could explore their genetic history together. It would be fun.

When they viewed the results six weeks later, their jaws dropped:

What they had believed all their lives — that they shared the same biological parents — was not true. The results instead showed that they were only half-siblings. While they shared the same mother, they had different fathers.

“So who’s your daddy?” Gottfried asked his sister, stunned.

To which she instantly replied: “Who’s your daddy?”

The two people who perhaps could’ve provided answers for them — their parents, George and Tina Gottfried — had died years before. Other older relatives who might’ve had information were long gone, too.

“I was shocked to such a degree that it didn’t seem real,” said Gottfried, who lives in Wyndmoor. “I’m a data guy. And here I am looking at data that is very clear — no ambiguity. We were not [full] brother and sister.”

At first, both Gottfried and Heller presumed the other sibling was born of the mystery father. But soon, Gottfried admits, he began to believe that the mystery father was probably his.

For one thing, in the siblings’ entire extended family, no one is close to six feet tall. Yet Gottfried is 6-foot-2 (his dad nicknamed him “Stretch”).

And growing up, Gottfried was “an academic whiz kid” who excelled at science and math and for whom school came easily. No one else in his family, he said, had his degree of academic prowess or technical bent (he’s an MIT- and Penn-educated software developer).

So he began doggedly pursuing a scientific trail of DNA connections, which he has now chronicled in a self-published book called Who’s My Daddy? (available on Kindle and in print-on-demand through Amazon).

Spoiler alert: Gottfried is indeed the offspring of the mystery father. But what makes Who’s My Daddy? a more compelling read beyond the now-ubiquitous tales of “DNA family reveals” is the question it raises regarding long-ago infertility treatments and the age-old yearning of young couples to become parents.

Gottfried and Heller began the inquiry into their half-sibling status by asking a first cousin, Roy — the son of their father’s brother — to undergo a genetic test, which he agreed to do. The results showed that Roy was related to Heller but not Gottfried. Which confirmed for Gottfried that his biological father was not the big-hearted, hard-working, and boisterous Bronx salesman who had loved and raised him.

Eager for more data to analyze, Gottfried submitted his DNA to three more testing companies. Subsequent results genetically linked him to others, to differing degrees, some of whom Gottfried tracked down. Some of them were helpful; others were not. Gottfried just kept plugging.

Along the way, he got wind of an intriguing episode of “This American Life” on PBS, which told the story of a Jewish man, also raised by parents from the lower middle class Bronx, who learned late in life that his father wasn’t his biological father.

Listening to it, “my jaw just about hit the floor,” said Gottfried, who was struck by the story’s similarity to his own.

The man had used DNA testing to uncover his genetic history. While his biological dad turned out to be his uncle, he mentioned that he’d once had suspicions about his mother’s obstetrician/gynecologist — a big-deal specialist whom his Bronx mom traveled all the way into Manhattan to see.

“Then I realized: Wait a minute. That’s the same story as my mom,” said Gottfried, who knew that his mother, after marrying his father, had for five years been unable to conceive. She finally conceived Gottfried after consulting a Park Avenue doctor (whose name Gottfried eventually learned).

And suddenly, Gottfried had not just a growing pile of data to analyze, but a hunch to explore: Did the doctor somehow figure into Gottfried’s origins?

“Piece by piece,” he said, he discovered what seemed like a possible link between people who seemed to be related to him — and people who were somewhere in the branches of the doctor’s family tree.

Finally, two people provided the breaks his investigation needed.

The first was a man named David Levine, whom tests indicated was Gottfried’s second cousin. When they connected, Levine had interesting information: The doctor who’d treated Gottfried’s mother was Levine’s father’s first cousin.

The second was a woman from California named Maimoona Ahmed who agreed to take a DNA test to help Gottfried uncover his own identity. She turned out to be Gottfried’s biological first cousin. Her father and the doctor had been brothers.

And at long last, Gottfried said, he knew who had fathered him.

Exactly how that came to be, Gottfried does not know. He cannot imagine, he says that, it was infidelity on his mother’s part. The doctor had been an early fertility practitioner, and his mother turned to him after five years of being unable to conceive.

Once he made his discovery, Gottfried sought to learn what he could about the doctor, a respected physician with a prestigious clientele whom Ahmed, his niece, remembers with great affection and esteem.

“The whole family always put him on a pedestal. We adored him,” said Ahmed, 77, of the doctor, who died in 2001. “He was so handsome, so charming.”

The doctor’s family came to the United States from Russia; Gottfried’s father’s family emigrated from Hungary. The doctor had been part of a field unit of physicians sent to help prisoners being liberated from Nazi concentration camps after World War II. Gottfried has a copy of a very moving letter that the doctor wrote home about what he saw.

Gottfried said he was able to identify and then contact the doctor’s now-adult children; he says they did not respond to his request to connect. But Gottfried has gotten to know four of his newly discovered second cousins and two first cousins, especially Ahmed, with whom he spent a day while in California a couple years ago.

“It was like a whole lifetime to catch up on,” he said.

Ahmed, meanwhile, was glad to help her newfound cousin.

“I’m not the sleuth he is,” she said, “but I love to put people together. I love family stories. My kids know all know about Joel. We’re all excited.”

Gottfried’s journey has only tightened his bond with his sister, Debbie Heller, who stayed by his side through every twist of his investigation.

“We’ve always been close, but this drew us even closer,” he said. “She was so supportive in helping me through this.”

And in his heart, George Gottfried — the dad who raised him to respect the working man, who passed on his zany sense of humor, who made him feel protected and loved — is still very much his father.

“His sperm was not used to create me, but he was my father in every sense of the word,” Gottfried said.

He’s glad for the revelations of the past few years, he said. They’ve made him more introspective, more appreciative of his unique life.

“Because you know what? As bizarre as this was, I do cherish who I am, and I’m happy with who I am,” he said. “I have my mother. I have my father who raised me. I have the father whose sperm started me off. It all came together, and I am happy with who I am. And I wanted to tell the story.”