Hello dear
Understand your concern.
Yes unprotected anal sex has high risk of UTI.
Anal canal contains lots of bacteria, after anal sex there is contact between genital tract and again unprotected vaginal intercourse lead to high chance of 
urinary tract infection.
E. coli, 
Staphylococcus saprophyticus (10 to 15 percent). Enterococcus, Klebsiella, Enterobacter, and Proteus  are main pathogens for UTI
Some time infection can be detected if it is in 
incubation period.
If problem persists you should both check for STDs.
Following are the risks factor for UTI:
Frequent intercourse, 
use of a diaphragm and/or spermicide,
obesity,
Urinary incontinence
unprotected vaginal intercourse with a partner  
unprotected anal sex
Poor hygiene before and after sex.
Following are advice for you.
- drinking plenty of fluids and not delaying urinating. 
- advised to wipe from front to back to prevent bacteria from entering the urethra, and to cleanse their genital area before and after sex
- Drink  fresh cranberry and orange juice
- Avoid anal sex if possible
- Use safer sex practice-use condoms and lubricants
 Treatment are below
1. three day course of 
trimethoprim/sulfamethoxazole (TMPSMX; Bactrim, Septra) is the current standard therapy,
2. with three days of trimethoprim or a fluoroquinolone (i.e., ofloxacin, norfloxacin [Noroxin], or 
ciprofloxacin [Cipro]) being equally effective.
3. 
Fluoroquinolones and 
nitrofurantoin become better options in your case for TMP-SMX resistance increases.
4.If oral drug is not possible, take ceftazidime parentrally.
You should shift to oral therapy with in 72 hr as you able to tolerate oral drugs.
Follow up urine culture after 14 days to confirm the eradication of bacteria.
Tablet Paracetamol 500 mg thrre times a day if fever is present.
Tablet cetrizine 4 mg once daily
Hope this advice help you..
Thank you. 
Get well soon.