Technically almost everything is possible (depending on how many resources you have at your disposal 😛 )
That said, here is what I think of first.
I would set up a Numeric eVar, while eVars technically store string values, a numeric eVar allows you to create essentially a incremental value as a dimension. (https://experienceleague.adobe.com/docs/analytics/admin/admin-tools/manage-report-suites/edit-report-suite/conversion-variables/conversion-var-admin.html?lang=en#counters)
Where you can pass +1 and have the value increment within the scope of the eVar (in this case Visit).
So on each item viewed, you would want to increment the eVar....
Your Cart Addition would happen after the view (and not touch the eVar at all)
Then you should be able to correlate the "Items Viewed" (counter eVar) to Cart Additions, since the eVar is set to Visit level expiry, so the last value set should be seen by the Cart Addition.
You will have to test this, as this is off the top of my head...
The other option would be to use something like a Session Storage Variable to track products viewed and add that information to the Cart Addition action, but I think you should be able to do this without setting a session storage item.