You’re right, if the new technology enters the public domain, it is no longer patent eligible. So if you can use the technology without revealing it to the public, it would still be eligible to receive a patent. The trick is that it is pretty hard to use the technology without revealing it to anyone, experimental use being an exception. The law allows for inventors to experiment and test their inventions without giving up the opportunity to receive a patent.
The answer will depend on how you used the technology. For example, if you post the algorithm online and ask others for suggestions, that would put the algorithm in the public domain so it would not be patent eligible. On the other hand, if you implement the algorithm into your website on a trial basis while collecting data to make improvements, that is an experimental use so it would not likely render the technology unpatentable.
There is another exception that may apply even if the technology has entered the public domain. After publishing the technology, the inventor would have a grace period of 12 months to apply for a patent. If the application is submitted before the 12 months is over, the technology will still be eligible for a patent.
I would suggest that you speak with a patent attorney about the specifics of your situation to determine whether your algorithm is patent eligible. If you are looking for a patent attorney, you should visit. Our attorneys have experience in all areas of patent law and have helped many others — also, the initial consultation is free, good luck!