Of course you can trace how ideologies form, that's the whole point here. The soil in which they grow are the material conditions in which people find themselves, the struggle between classes being the primary (but not only) driving force of those material conditions.