Conformity is a common phenomenon existing both in humans and in social animals, which has strong impact on collective behaviors. The effects of conformity on cooperation in a population have been widely explored in evolutionary games. Conformity-driven individuals tend to follow the strategy adopted by the majority of their neighbors. In most previous studies, the individuals take the half-number of their neighbors as the threshold for identifying the majority. However, in reality, the individuals may determine the majority based on a different threshold. For example, they might not conform unless the proportion of the majority reaches three-quarters. In contrast, it is also possible that the individuals have a lower reference than the half for majority. Here, we study the effects of the conformity threshold on cooperation in spatial prisoner's dilemma games. Our results show that there always exists an optimal conformity threshold for the population to maximize the cooperation level. Moreover, we find that the optimal conformity threshold depends on the payoff parameter of the game. Besides, the robustness of the results has been checked and we find that the simulation results are qualitatively unchanged when the different network scheme is used.