One other note, I used 1/4" cylinder neodymium magnets that I just dropped on one of the chain links as the magnetic source. This has worked well for almost a year without any issues of the magnet jumping or slipping.
Probably the easiest way to get your magnet attached if you have chain drive.