I've seen some sentences, and some of them use
通过上网聊天，我认识了很多新朋友 Through online chat, I meet many new friends
whereas for another case, it uses
网上购物是最流行的生活方式 Online shopping is the most popular lifestyle.
In both sentences, they mean as "online". But I'm a bit confused on the word order, when should we use
上网 and when should we use