What you need to do beforehand:

1) Unlock your bootloader.

2) Install your device's build of TWRP.

3) Pick a custom ROM complied for your device. (Check XDA)

4) Download Magisk and NanoMod. Magisk: http://tinyurl.com/zjd4plj | NanoMod: http://tinyurl.com/yddyb9vh

A) You want the zips called "NanoMod-microG-*", "NanoMod-patcher-*", and "NanoMod-setupwizard-*".

* = The version number.

Here's what to do:

1) Reboot into TWRP.

2) Wipe system, data, cache, dalvik/art cache, and internal storage.

3) Flash your ROM of choice.

A) Flash Magisk.

B) Flash "NanoMod-setupwizard-*" and chose the options you want. NOTE: Some of the options only work in the full nanomod packages. Just deselect the ringtones, debloater, and apps. Check the swype and and other options as you see fit.

C) Flash "NanoMod-microG-*".

4) Let the OS boot up.

5) Reboot back into recovery.

6) Flash "NanoMod-patcher-*". There may be an error at the end. This is still fine.

6) Boot the OS.

7) Open the microG app and use the self check. There should be a checkmark next to "system spoofs signature". (If it doesn't then you skipped a step.)

8) In the microG app, open the option called "UnifiedNlp Settings".

9) Click the top option, click the checkbox on the popup. Allow permissions as needed. Do the same with the bottom option.

10) In the microG app, open the option called "Google Cloud Messaging" and turn it on. (This is how apps send you push notifications.)

A) Go back to the app's main screen. It'll ask if it can can ignore battery optimizations. This is up to you. I'd say yes.

OPTIONAL) Go back to the home screen and click on the play store icon (if you selected the option to intsall it). It'll ask you to sign in. You'll get and error after you sign in. Just go to the next step.

11) Reboot.