If you need to create animated GIF files on a regular basis, GifGun for After Effects is well worth it.
https://aescripts.com/gifgun/
As long as the animation is 500 frames or less, you can render a movie file from After Effects with transparency and then convert that to an animated GIF with transparency in Photoshop.
Assuming that you can see the Transparency Grid in After Effects, add your Comp to the After Effects Render Queue, set the Render Settings template to "Best Settings", and the Output Module to "High Quality with Alpha". Open the resulting movie file in Photoshop (note, on the macOS side if you're on a M1-based Mac you may still have to open Photoshop using Rosetta) and use File > Export > Save for Web (Legacy)... to set the GIF options and save it. If you're using an older version of After Effects (2021 or older), you'll need to use the "Lossless with Alpha" Output Module template.
You may have noticed that there's an "Animated GIF" Format option in Adobe Media Encoder Queue. Avoid this unless you're converting short video clips to animated GIF - it treats anaimted GIF like it's video when it is not.