{"action":"closed","issue":{"url":"https://api.github.com/repos/affiliatewp/AffiliateWP/issues/915","labels_url":"https://api.github.com/repos/affiliatewp/AffiliateWP/issues/915/labels{/name}","comments_url":"https://api.github.com/repos/affiliatewp/AffiliateWP/issues/915/comments","events_url":"https://api.github.com/repos/affiliatewp/AffiliateWP/issues/915/events","html_url":"https://github.com/affiliatewp/AffiliateWP/issues/915","id":112047982,"number":915,"title":"\"Credit last referrer\" option breaking referrals, generating multiple visit IDs","user":{"login":"sumobi","id":52581,"avatar_url":"https://avatars.githubusercontent.com/u/52581?v=3","gravatar_id":"","url":"https://api.github.com/users/sumobi","html_url":"https://github.com/sumobi","followers_url":"https://api.github.com/users/sumobi/followers","following_url":"https://api.github.com/users/sumobi/following{/other_user}","gists_url":"https://api.github.com/users/sumobi/gists{/gist_id}","starred_url":"https://api.github.com/users/sumobi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumobi/subscriptions","organizations_url":"https://api.github.com/users/sumobi/orgs","repos_url":"https://api.github.com/users/sumobi/repos","events_url":"https://api.github.com/users/sumobi/events{/privacy}","received_events_url":"https://api.github.com/users/sumobi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/affiliatewp/AffiliateWP/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/affiliatewp/AffiliateWP/milestones/51","html_url":"https://github.com/affiliatewp/AffiliateWP/milestones/1.7.9","labels_url":"https://api.github.com/repos/affiliatewp/AffiliateWP/milestones/51/labels","id":1372418,"number":51,"title":"1.7.9","description":null,"creator":{"login":"pippinsplugins","id":1034109,"avatar_url":"https://avatars.githubusercontent.com/u/1034109?v=3","gravatar_id":"","url":"https://api.github.com/users/pippinsplugins","html_url":"https://github.com/pippinsplugins","followers_url":"https://api.github.com/users/pippinsplugins/followers","following_url":"https://api.github.com/users/pippinsplugins/following{/other_user}","gists_url":"https://api.github.com/users/pippinsplugins/gists{/gist_id}","starred_url":"https://api.github.com/users/pippinsplugins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pippinsplugins/subscriptions","organizations_url":"https://api.github.com/users/pippinsplugins/orgs","repos_url":"https://api.github.com/users/pippinsplugins/repos","events_url":"https://api.github.com/users/pippinsplugins/events{/privacy}","received_events_url":"https://api.github.com/users/pippinsplugins/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":8,"state":"open","created_at":"2015-10-23T13:41:13Z","updated_at":"2015-11-09T15:19:13Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2015-10-18T22:51:42Z","updated_at":"2015-11-09T15:19:13Z","closed_at":"2015-11-09T15:19:13Z","body":"So far there are 3 support tickets related to this:\r\nhttps://secure.helpscout.net/conversation/130952542/19134/\r\nhttps://secure.helpscout.net/conversation/131147259/19196/\r\nhttps://secure.helpscout.net/conversation/131144914/19193/\r\n\r\nHere's a summary of 2 scenarios where it fails:\r\n\r\n## Scenario 1\r\nWhen the customer uses an affiliate's ID and then moves between pages, the visit ID eventually becomes `-2`. If you stay on the same page and refresh each time, a new visit is stored in the DB. The referral is still created in my testing however since the visit ID changes to `-2`, the visit is not updated to show as converted. The affiliate ID remains intact (unlike scenario 2 below).\r\n\r\n## Scenario 2\r\nA customer uses an affiliate's referral URL, lands on the homepage, then registers as a WP user. The affiliate ID is wiped from the cookies when visiting the WP user registration page, and then coming back to the site. Since the affiliate's ID is wiped, no referral is created when the customer purchases. Like scenario 1 above, the visit ID also changes to `-2`.\r\n\r\n___\r\n\r\n### Steps to reproduce scenario 1\r\n\r\n- MS installation\r\n- `Credit Last Referrer` enabled\r\n- EDD integration (but also broken on WooCommerce)\r\n- logged in or logged out user\r\n\r\n1. Make sure `Credit Last Referrer` is enabled from the settings\r\n2. Use an affiliate's referral URL to the site homepage (could be any page) and a visit will be created as usual. Note the visit ID set in the `affwp_ref_visit_id` cookie.\r\n3. Refresh the current page. The visit ID increments by `1`. If you keep refreshing, it keeps incrementing by `1` and more and more visits are stored in Affiliates -> Visits.\r\n4. Click to go to another page, the visit ID increments again by 1 again. Refresh that page and the visit now changes to `-2`. Since the visit ID changes to `-2`, when the referral is generated, it doesn't show the visit as converted.\r\n\r\n### Steps to reproduce scenario 2\r\n\r\n- Single site installation:\r\n- Using EDD integration\r\n- `Credit Last Referrer` enabled\r\n- Logged out user \r\n\r\n1. Use an affiliate's referral URL to the site homepage and a visit will be created as usual. Note the visit ID set in the `affwp_ref_visit_id` cookie.\r\n2. Add /wp-login.php?action=register to the URL to simulate going to register as a user\r\n3. One the WP registration screen, click the \"Back site\" link and the bottom\r\n4. Look at the cookies and you'll see that the `affwp_ref`cookie has been removed. The `affwp_ref_visit_id` cookie shows another incremented visit ID until you click to go to another page, at which point it then changes to `-2`.\r\n\r\nMoving around pages also increments the visit ID as per the other scenario and it eventually becomes `-2`."}}