The incident happened at about 15:50 BST on Saturday between junctions 36 and 37, leaving one lane closed and traffic slow, South Wales Police said.
Road authorities said the lane had since reopened and traffic had returned to normal.
The woman, who was taken to Cardiff's University Hospital of Wales, suffered non-life-threatening injuries.
A woman has been airlifted to hospital after a car spun off the eastbound M4 near Bridgend.