The CMS experiment at the LHC has measured the differential cross sections of Z bosons decaying to pairs of leptons, as functions of transverse momentum and rapidity, in lead-lead collisions at a nucleon-nucleon center-of-mass energy of 5.02 TeV. The measured Z boson elliptic azimuthal anisotropy coefficient is compatible with zero, showing that Z bosons do not experience significant final-state interactions in the medium produced in the collision. Yields of Z bosons are compared to Glauber model predictions and are found to deviate from these expectations in peripheral collisions, indicating the presence of initial collision geometry and centrality selection effects. The precision of the measurement allows, for the first time, for a data-driven determination of the nucleon-nucleon integrated luminosity as a function of lead-lead centrality, thereby eliminating the need for its estimation based on a Glauber model.