Apple is tapping new technology—called “differential privacy”—to garner insight into user behavior, in an effort to keep pace with rivals’ insights without violating its privacy pledges.