Two important aspects are; the intended use the frame was designed for and the shock measurements.
Frames are designed for specific use in mind regardless of what you want to do with it. This design accommodates specific types of shocks. Whether Air, Coil or a combo or a 'piggy-back' shock. Some design are more flexible. For example my enduro design will struggle to get a Cane Creek Double barrel in. But then I've also seen many where people have mounted shocks upside down or back to front because it works.
Be realistic, measure the space available while sprung and also when compressed.
The shock's (and parts') size.
Two key measurements here. Eye-to-eye (length of the shock) and Stroke (the amount of displacement) length.
- Eye-to-eye is measured from the middle of one mounting eyelet to the middle of the next.
- Stroke is the difference in shock length between fully compressed and fully extended. In other words the total movement the shock can accommodate. This is not the bike travel figure but instead the movement that gives you the bike travel.
Those are your most important 2 measures.
However, take note of the mounting hardware. The bolts have a specific width and does the bushings/spacers. You need to know if the new shock comes with mounting bolts/kit that will fit. You may be able to reuse the old set if they compatible. You may also need to use a bearing tool to get them out. But it varies.
Yes, you can do it yourself. You need to remember to release all the air/compress the coil etc. If you haven't done this before, you best ask your LBS if you can have a look while they do it for you.