PurposeHealth care insurance claims databases are becoming a more common data source for studies of medication safety during pregnancy. While pregnancies have historically been identified in such databases by pregnancy outcomes, International Classification of Diseases, 10th revision Clinical Modification (ICD‐10‐CM) Z3A codes denoting weeks of gestation provide more granular information on pregnancies and pregnancy periods (i.e., start and end dates). The purpose of this study was to develop a process that uses Z3A codes to identify pregnancies, pregnancy periods, and links infants within a commercial health insurance claims database.MethodsWe identified pregnancies, gestation periods, pregnancy outcomes, and linked infants within the US‐based Optum Research Database between 2015 and 2020 via a series of algorithms utilizing diagnosis and procedure codes on claims. The diagnosis and procedure codes included ICD‐10‐CM codes, Current Procedural Terminology (CPT) codes, and Healthcare Common Procedure Coding System (HCPCS) codes.ResultsWe identified 1 030 874 pregnancies among 841 196 women of reproductive age. Of pregnancies with livebirth outcomes, 84% were successfully linked to infants. The prevalence of pregnancy outcomes (livebirth, stillbirth, ectopic, molar, and abortion) was similar to national estimates.ConclusionsThis process provides an opportunity to study drug safety and care patterns during pregnancy and may be replicated in other claims databases containing ICD‐10‐CM, CPT, and HCPCS codes. Work is underway to validate and refine the various algorithms.