I have a simple web page where I show my CartoDB map and a dataset. I want to know if there is any way to insert new rows into my CartoDB dataset from code, so external users can add points to the map by clicking on it.
You can do this by using CartoDB in combination with the Leaflet Draw plugin. You can check all the information in this blogpost.
Basically, with the plugin people will be able to draw geometries on top of your map. You'll need to save these geometries in your database, and you can do this, as the example shows, by adding a security definer to your table so that you can perform write actions on it without being authenticated.
CartoDB also lists some libraries for the SQL API that you can use from your backend in order to insert the data.