Last active
October 24, 2018 20:58
-
-
Save rsisco/b5da4ffb261504c3ed299be3ce1e5c1a to your computer and use it in GitHub Desktop.
Compare M1 URL rewrites to Google Analytics data to find GA requests that are missing from rewrites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script assumes that a table has been created (m1_url_export) containing the output generated by https://gist.github.com/rsisco/a14b3383b2ab9f6435139d107e428a43 | |
# as well as a table (google_analytics_export) that contains page request paths and counts from Google Analytics: | |
# Select the path without the query string | |
SELECT SUBSTRING_INDEX(page, '?', 1) AS page, sum(pageviews) AS pageviews FROM google_analytics_export AS gae | |
LEFT JOIN m1_url_export AS m ON gae.page = m.url and gae.store_id = m.store_id | |
# Only include results with no M1 match | |
WHERE m.url IS NULL | |
# Exclude paths we don't need to know about to keep the list pared down | |
AND page NOT LIKE '/catalog/product/gallery/%' | |
AND page NOT LIKE '/checkout/%' | |
AND SUBSTRING_INDEX(page, '?', 1) NOT IN ('/', '') | |
# Provide desired store ID | |
AND m.store_id = ? | |
# Group by requested page (minus query string) | |
GROUP BY SUBSTRING_INDEX(page, '?', 1) | |
ORDER BY pageviews DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
USAGE: