{"action":"opened","number":7817,"pull_request":{"url":"https://api.github.com/repos/Automattic/jetpack/pulls/7817","id":141973733,"html_url":"https://github.com/Automattic/jetpack/pull/7817","diff_url":"https://github.com/Automattic/jetpack/pull/7817.diff","patch_url":"https://github.com/Automattic/jetpack/pull/7817.patch","issue_url":"https://api.github.com/repos/Automattic/jetpack/issues/7817","number":7817,"state":"open","locked":false,"title":"Google Analytics: Add support for IP anonymization and basic ecommerce tracking","user":{"login":"allendav","id":1595739,"avatar_url":"https://avatars1.githubusercontent.com/u/1595739?v=4","gravatar_id":"","url":"https://api.github.com/users/allendav","html_url":"https://github.com/allendav","followers_url":"https://api.github.com/users/allendav/followers","following_url":"https://api.github.com/users/allendav/following{/other_user}","gists_url":"https://api.github.com/users/allendav/gists{/gist_id}","starred_url":"https://api.github.com/users/allendav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allendav/subscriptions","organizations_url":"https://api.github.com/users/allendav/orgs","repos_url":"https://api.github.com/users/allendav/repos","events_url":"https://api.github.com/users/allendav/events{/privacy}","received_events_url":"https://api.github.com/users/allendav/received_events","type":"User","site_admin":false},"body":"Fixes #7777 #7778 \r\n\r\nWORK IN PROGRESS\r\n\r\n#### Changes proposed in this Pull Request:\r\n\r\n* The present Google Analytics module in Jetpack only looks for the tracking code (the UA code) in settings.\r\n* We are adding three other fields to the jetpack_wga option  (and, as a separate PR, to the endpoint that sets that option)\r\n* The three other fields are\r\n\r\n1. anonymize_ip - allows IP anonymization. It defaults to off.\r\n2. ec_track_purchases - syncs WooCommerce order amounts and items to Google Analytics as orders are received. Defaults to off.\r\n3. ec_track_add_to_cart - notifies Google Analytics (as an event) when customers add items to their carts. Defaults to off.\r\n\r\n* In addition to the endpoint, there will be a wp-calypso PR to allow the user to control these new settings.  For now, for testing this PR, you'll need to manipulate the option \"manually.\"\r\n\r\n#### Testing instructions:\r\n\r\n* Sign up for a Google Analytics tracking code for your test site, e.g. UA-12345678-1 \r\n* Install, activate and connect Jetpack\r\n* Install and activate WooCommerce\r\n* Create a product with no SKU and at least two categories\r\n* Create another product with a SKU and at least two categories\r\n* Replace the modules/google-analytics/wp-google-analytics.php file with the file from this branch\r\n* \"Manually\" set (e.g. just do something like hack Hello Dolly) the jetpack_wga option to\r\n\r\n```\r\narray(\r\n\t'code' => '',\r\n\t'anonymize_ip' => 0,\r\n\t'ec_track_purchases' => 0,\r\n\t'ec_track_add_to_cart' => 0\r\n);\r\n```\r\n\r\n* Visit either product page.\r\n* View the source and 1) ensure the Google Analytics script (ga.js) is never referenced and 2) no jQuery is present to hook .single_add_to_cart_button or .add_to_cart_button\r\nelements.\r\n\r\n* \"Manually\" set the jetpack_wga option to\r\n\r\n```\r\narray(\r\n\t'code' => 'UA-12345678-1',\r\n\t'anonymize_ip' => 0,\r\n\t'ec_track_purchases' => 0,\r\n\t'ec_track_add_to_cart' => 0\r\n);\r\n```\r\n\r\n* Visit either product page.\r\n* View the source and 1) ensure the Google Analytics script (ga.js) is present but that no jQuery is present to hook .single_add_to_cart_button or .add_to_cart_button elements.\r\n\r\n* \"Manually\" set the jetpack_wga option to\r\n\r\n```\r\narray(\r\n\t'code' => 'UA-12345678-1',\r\n\t'anonymize_ip' => 1,\r\n\t'ec_track_purchases' => 0,\r\n\t'ec_track_add_to_cart' => 0\r\n);\r\n```\r\n\r\n* Visit either product page.\r\n* View the source and 1) ensure the Google Analytics script (ga.js) is present and that the _anonymizeIp element is present\r\n\r\n* \"Manually\" set the jetpack_wga option to\r\n\r\n```\r\narray(\r\n\t'code' => 'UA-12345678-1',\r\n\t'anonymize_ip' => 0,\r\n\t'ec_track_purchases' => 1,\r\n\t'ec_track_add_to_cart' => 0\r\n);\r\n```\r\n\r\n* In your Google Analytics Dashboard, go to Admin for your site (it looks like a gear in the lower left corner)\r\n* Under View select Ecommerce Settings\r\n* Enable Ecommerce if you haven't already. DO NOT ENABLE ENHANCED ECOMMERCE AT THIS TIME.\r\n\r\n* Back on your test site, Complete the purchase of any item using a gateway like Check Payment.\r\n* Return to your Google Analytics Dashboard and go to Conversions and then Ecommerce\r\n* Set the date range to today\r\n* Make sure you see the sale and that the details are correct\r\n\r\n* \"Manually\" set the jetpack_wga option to\r\n\r\n```\r\narray(\r\n\t'code' => 'UA-12345678-1',\r\n\t'anonymize_ip' => 0,\r\n\t'ec_track_purchases' => 1,\r\n\t'ec_track_add_to_cart' => 1\r\n);\r\n```\r\n\r\n* Visit each product page, adding the product to your cart.\r\n* In your Google Analytics Dashboard, go to Real-time and then Events\r\n* Make sure you see the addition of the SKU less and the SKU product and that the details are correct\r\n\r\n#### Proposed changelog entry for your changes:\r\n\r\n* Google Analytics: Add support for IP anonymization and basic WooCommerce tracking\r\n","created_at":"2017-09-19T22:43:43Z","updated_at":"2017-09-19T22:43:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":{"login":"allendav","id":1595739,"avatar_url":"https://avatars1.githubusercontent.com/u/1595739?v=4","gravatar_id":"","url":"https://api.github.com/users/allendav","html_url":"https://github.com/allendav","followers_url":"https://api.github.com/users/allendav/followers","following_url":"https://api.github.com/users/allendav/following{/other_user}","gists_url":"https://api.github.com/users/allendav/gists{/gist_id}","starred_url":"https://api.github.com/users/allendav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allendav/subscriptions","organizations_url":"https://api.github.com/users/allendav/orgs","repos_url":"https://api.github.com/users/allendav/repos","events_url":"https://api.github.com/users/allendav/events{/privacy}","received_events_url":"https://api.github.com/users/allendav/received_events","type":"User","site_admin":false},"assignees":[{"login":"allendav","id":1595739,"avatar_url":"https://avatars1.githubusercontent.com/u/1595739?v=4","gravatar_id":"","url":"https://api.github.com/users/allendav","html_url":"https://github.com/allendav","followers_url":"https://api.github.com/users/allendav/followers","following_url":"https://api.github.com/users/allendav/following{/other_user}","gists_url":"https://api.github.com/users/allendav/gists{/gist_id}","starred_url":"https://api.github.com/users/allendav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allendav/subscriptions","organizations_url":"https://api.github.com/users/allendav/orgs","repos_url":"https://api.github.com/users/allendav/repos","events_url":"https://api.github.com/users/allendav/events{/privacy}","received_events_url":"https://api.github.com/users/allendav/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/jetpack/pulls/7817/commits","review_comments_url":"https://api.github.com/repos/Automattic/jetpack/pulls/7817/comments","review_comment_url":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/jetpack/issues/7817/comments","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/439382dc8e761e46f3fbe6f23b43d59750158653","head":{"label":"Automattic:add/7777-ga-anonymize-ip","ref":"add/7777-ga-anonymize-ip","sha":"439382dc8e761e46f3fbe6f23b43d59750158653","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":15231212,"name":"jetpack","full_name":"Automattic/jetpack","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/jetpack","description":"Increase your traffic, view your stats, speed up your site, and protect yourself from hackers with Jetpack.","fork":false,"url":"https://api.github.com/repos/Automattic/jetpack","forks_url":"https://api.github.com/repos/Automattic/jetpack/forks","keys_url":"https://api.github.com/repos/Automattic/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/jetpack/teams","hooks_url":"https://api.github.com/repos/Automattic/jetpack/hooks","issue_events_url":"https://api.github.com/repos/Automattic/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/jetpack/events","assignees_url":"https://api.github.com/repos/Automattic/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/jetpack/tags","blobs_url":"https://api.github.com/repos/Automattic/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/jetpack/languages","stargazers_url":"https://api.github.com/repos/Automattic/jetpack/stargazers","contributors_url":"https://api.github.com/repos/Automattic/jetpack/contributors","subscribers_url":"https://api.github.com/repos/Automattic/jetpack/subscribers","subscription_url":"https://api.github.com/repos/Automattic/jetpack/subscription","commits_url":"https://api.github.com/repos/Automattic/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/jetpack/merges","archive_url":"https://api.github.com/repos/Automattic/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/jetpack/downloads","issues_url":"https://api.github.com/repos/Automattic/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/jetpack/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/jetpack/deployments","created_at":"2013-12-16T16:43:01Z","updated_at":"2017-09-17T00:54:11Z","pushed_at":"2017-09-19T22:41:40Z","git_url":"git://github.com/Automattic/jetpack.git","ssh_url":"git@github.com:Automattic/jetpack.git","clone_url":"https://github.com/Automattic/jetpack.git","svn_url":"https://github.com/Automattic/jetpack","homepage":"https://jetpack.com/","size":197658,"stargazers_count":693,"watchers_count":693,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":441,"mirror_url":null,"open_issues_count":916,"forks":441,"open_issues":916,"watchers":693,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"94dfd5b0a48ed2cc1332e4b09b615299bd674ade","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":15231212,"name":"jetpack","full_name":"Automattic/jetpack","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars1.githubusercontent.com/u/887802?v=4","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/jetpack","description":"Increase your traffic, view your stats, speed up your site, and protect yourself from hackers with Jetpack.","fork":false,"url":"https://api.github.com/repos/Automattic/jetpack","forks_url":"https://api.github.com/repos/Automattic/jetpack/forks","keys_url":"https://api.github.com/repos/Automattic/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/jetpack/teams","hooks_url":"https://api.github.com/repos/Automattic/jetpack/hooks","issue_events_url":"https://api.github.com/repos/Automattic/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/jetpack/events","assignees_url":"https://api.github.com/repos/Automattic/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/jetpack/tags","blobs_url":"https://api.github.com/repos/Automattic/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/jetpack/languages","stargazers_url":"https://api.github.com/repos/Automattic/jetpack/stargazers","contributors_url":"https://api.github.com/repos/Automattic/jetpack/contributors","subscribers_url":"https://api.github.com/repos/Automattic/jetpack/subscribers","subscription_url":"https://api.github.com/repos/Automattic/jetpack/subscription","commits_url":"https://api.github.com/repos/Automattic/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/jetpack/merges","archive_url":"https://api.github.com/repos/Automattic/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/jetpack/downloads","issues_url":"https://api.github.com/repos/Automattic/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/jetpack/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/jetpack/deployments","created_at":"2013-12-16T16:43:01Z","updated_at":"2017-09-17T00:54:11Z","pushed_at":"2017-09-19T22:41:40Z","git_url":"git://github.com/Automattic/jetpack.git","ssh_url":"git@github.com:Automattic/jetpack.git","clone_url":"https://github.com/Automattic/jetpack.git","svn_url":"https://github.com/Automattic/jetpack","homepage":"https://jetpack.com/","size":197658,"stargazers_count":693,"watchers_count":693,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":441,"mirror_url":null,"open_issues_count":916,"forks":441,"open_issues":916,"watchers":693,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/7817"},"html":{"href":"https://github.com/Automattic/jetpack/pull/7817"},"issue":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/7817"},"comments":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/7817/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/7817/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/7817/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/jetpack/statuses/439382dc8e761e46f3fbe6f23b43d59750158653"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":146,"deletions":10,"changed_files":1}}
{"actor":{"display_login":"allendav"}}