The lawful and unlawful is one of the biggest issues that have been tackled by many scholars and is still in need of more discussions because of the urgency of some matters, such as the question you have raised.
According to a group of scholars, using soaps, shampoo, etc., that contain animal by-products is permissible.
Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, stated: As ruled by a number of scholars and jurists, we need not be overly concerned about the issue of soaps and cosmetics made up of animal by-products because they can be considered as lawful even if they contain animal by-products that are often considered impure. They have made this ruling by invoking two principles of jurisprudence: One is the principle of istihaalah (Arabic for: transformation of a substance in such a way that it is turned into a wholly different product). The analogy is that of alcohol turned into vinegar. For, although alcohol is forbidden, vinegar is lawful. Therefore, soaps and cosmetics, although made up of animal by-products, have undergone drastic changes, and thus they do not remain the same; accordingly, they can be ruled as halal (Arabic for: allowed according to Islamic teachings).
There is also another principle known as ‘umoum al-balwa (Arabic for: common predicament) and, therefore, unavoidable. Based on these things, a number of scholars and jurists have ruled that we need not shun such products, as they can be deemed as lawful for use because of unavoidable predicament.
There is, however, another view on this: avoiding such products altogether. According to jusrists who hold this view, as these impure or unlawful ingredients have been added deliberately to producing them, they cannot be judged as lawful. For, in their opinion, deliberately taking alcohol and turning it into vinegar does not render the process lawful. Likewise, soaps and cosmetics, to which such ingredients have been deliberately added, cannot be deemed as lawful.
however, I must rush to add: No one has any doubt about the lawfulness of soaps and cosmetics made of lawful and pure animal by-products.
If you follow the second view, you are advised to avoid such products altogether, especially when there is a doubt as to whether they came from pork-by products. In such a case, it is best for us to follow the rule, “When in doubt, leave that which is doubtful in favor of that which is not doubtful.”
We should also point out that there is no shortage of products that can be judged as totally free of such by-products. Although one needs to do some research to identify such products, it is not hard to do so. You can also contact the manufacturers directly.
May Allah make us self-sufficient with that which He has declared as lawful for us so that we are not forced to resort to that which is unlawful, amen.