I want to write some code so that when the author creates an item of a particular template, the data source for that item is converted to Guid.
I know that there is an option to manually do it, but I'd like it done for all items of that template when they are created:
I was thinking of doing in on the ItemCreated event in C#.
I did try doing it on the branch template but hat introduced another problem where for every item, it started storing the data for that page under the branch template instead - so this definitely doesn't work.
Thanks!

Do you really need to do this? From what I remember, the "Convert data sources to GUID" script was basically a tool to convert paths from data entered in very old Sitecore versions. Sitecore has stored the datasource as guid internally for many years. I don't remember from what version, but I think this applies to at least Sitecore 7 and above.
If you still want tob build such feature, you can make a processor that hooks into the
item:savingpipeline, check if any of the__Renderingsor__Final Renderingsfields are modified, parse the xml content and find any<r>rendering elements having adsdatasource attribute (note the optional namespaces). The thedsattribute is a path pointing to an existing item, replace it with its ID.