I own a Microsoft Lumia 435 with Windows Phone 8.1 and I want to track in in case it is stolen. The problem that, in case the phone is stolen, it is very likely that it will be factory reset, thus the standard procedure to find it will not work. Thus I want to install a tracking app that will not be erased in case the phone is factory reset. I know that this is possible in Android if the phone has root access. Is there any analog procedure in Windows Phone?
There are no public root hacks for WP8.x at this time. However, there are hacks that allow adding files to the system partition, which is not completely erased upon hard reset (although some stuff in it will get overwritten).
You could, in theory, add an app and the app's license key to the system directory (Samsung, for example, stores the install package for their Diagnosis app in the \Windows\System32 directory). You'd then need to add a configuration instruction to install the app using that license key, in a way that the phone would preserve and process the new/edited file after a hard reset. I'm not sure what the best way to do that would be.
Your app would also need to start working, in the background, immediately upon installation, though. This is not available for third-party apps. In fact, it's something that WP8.x explicitly prohibits apps from doing. Maybe there's a first-party capability that could do this - I don't know of one, but there's tons of capabilities beyond what "normal" developers are allowed access to, and I don't know what they all do - but then you wouldn't be allowed to publish the app.
Realistically, doing this requires firmware or OS support, and that means manufacturer or Microsoft (which are sometimes the same thing) support. They aren't going to go for that, since it would be a huge privacy nightmare if there was a way to track a phone after you, say, sold it to somebody else.
Your best bet would probably be the IMEI (International Mobile Equipment Identifier). That is a number, unique to each phone and stored below the OS level, that can be used to identify a phone even if it is factory reset and the SIM card is replaced. It's often possible to block the IMEI of a stolen phone so that it won't work on any of the nearby mobile networks, if you can present convincing evidence that it was stolen.