At present, the optimization of the plunger mechanism is shale gas wells is mostly based on empirical methods, which lack a relevant rationale and often are not able to deal with the quick variations experienced by the production parameters of shale gas wells in comparison to conventional gas wells. In order to mitigate this issue, in the present work, a model is proposed to loosely couple the dynamics of gas inflow into shale gas wells with the dynamics of the liquid inflow. Starting from the flow law that accounts for the four stages of movement of the plunger, a dynamic model of the plunger lift based on the real wellbore trajectory is introduced. The model is then tested against 5 example wells, and it is shown that the accuracy level is higher than 90%. The well 'switch' , optimized on the basis of simulations based on such a model, is tested through on-site experiments. It is shown that, compared with the original switch configuration, the average production of the sample well can be increased by about 15%.