In Varieties, James explains his take on religion and its relation with the real world. For example, he makes it abundantly clear that he feels religious feeling are just actual feelings in disguise. For example, when someone has "religious faith", they simply have faith in themselves, but they don't know how to express that without the thought of religion.
James explains that religion had a bad origin, and was likely originally used to manipulate people. However, people have adapted the philosophies to be positive for themselves and their community over time, which has switched it from a bad thing to a good thing. Although James does not specifically say whether or not he himself is a believer in any type of religion, it is implied he is not.
Later in the book, James explains that things in the real world, like people taking drugs to feel more "mystical", are a connection that true believers honestly feel that they have with God. Because religion is born from the natural idea of human nature, there will be inevitable physical effects that the practice has on the species.
It is important to note that James bases his work, published in the early 1900's, solely on Christianity. In this way, it fails to capture many of the deep cultural aspects of religion, such as those that have been around longer, or polytheistic religions. Although James does explain some cultural aspects of religion, which is a large building block of it, he mostly considers the psychological root of the practice.