Solved. The solution is to convert the query to a subquery and then use the WHERE clause to filter by rank:
SELECT *
FROM (SELECT tag_id, geo_country, sum(imps),
RANK() OVER (PARTITION BY tag_id ORDER BY SUM(imps) DESC) AS rank
FROM table1
WHERE tag_id IN (2013150,1981153)
AND ymd > CURRENT_DATE - 3
GROUP BY 1,2) as t2
WHERE t2.rank <=5;