Distinguish between a sign up and a login

In case you’re using database connection (and not federated / social logins):

Instead of putting the logic in a Rule (which gets executed upon user authentication), you could instead use a post-user registration hook, which is only called upon signup and which you can use to call your backend.

In case above doesn’t work because you’re not just using database connections, and would go with a Rule: why not create the record (based on loginsCount as you do) directly from within the Rule (via an authenticated API call to your backend that creates the record in your db). Then you don’t need to fiddle around with the redirect URL.

Changing the redirect URL is not necessary and also seems to be the wrong approach especially because the writing to your database does not require any kind of user interaction, which is the scenario that such redirect is intended for.