Ruwen made a post about determining if its a new page or and update when lisening to the publish event. Could check it out here.
You need to add an event handler to handle the On publish page event for the EPiSever
In your page initializer add
DataFactory.Instance.PublishedPage += new PageEventHandler(Instance_PublishedPage);
This will create a handler as below
void Instance_PublishedPage(object sender, PageEventArgs e)
//put your code here