Background: Phenotypic heterogeneity and complicated gene-environment interplay in etiology are among the primary factors that hinder the identification of genetic variants associated with cocaine use disorder. Methods: To detect novel genetic variants associated with cocaine use disorder, we derived disease traits with reduced phenotypic heterogeneity using cluster analysis of a study sample (n = 9965). We then used these traits in genome-wide association tests, performed separately for 2070 African Americans and 1570 European Americans, using a new mixed model that accounted for the moderating effects of 5 childhood environmental factors. We used an independent sample (918 African Americans, 1382 European Americans) for replication. Results: The cluster analysis yielded 5 cocaine use disorder subtypes, of which subtypes 4 (n = 3258) and 5 (n = 1916) comprised heavy cocaine users, had high heritability estimates (h 2 = 0.66 and 0.64, respectively) and were used in association tests. Seven of the 13 identified genetic loci in the discovery phase were available in the replication sample. In African Americans, rs114492924 (discovery p = 1.23 × E −8), a single nucleotide polymorphism in LINC01411, was replicated in the replication sample (p = 3.63 × E −3). In a meta-analysis that combined the discovery and replication results, 3 loci in African Americans were significant genome-wide: rs10188036 in TRAK2 (p = 2.95 × E −8), del-1:15511771 in TMEM51 (p = 9.11 × E −10) and rs149843442 near LPHN2 (p = 3.50 × E −8). Limitations: Lack of data prevented us from replicating 6 of the 13 identified loci. Conclusion: Our results demonstrate the importance of considering phenotypic heterogeneity and gene-environment interplay in detecting genetic variations that contribute to cocaine use disorder, because new genetic loci have been identified using our novel analytic method.