Skip to content

Instantly share code, notes, and snippets.

-- Create the long and short range (in days) for the trend calculation. See the explanation in the blog for the proper use of these values.
#Create dataset with all onsite searches based on unique visitors and keyword+date
#Only picking up words that do not contain other values then text or only numbers
# Excluding often misused listerpages when CPC is the channel
WITH preselect AS
(
SELECT DISTINCT(date) as date_derived
, UPPER(productSKU) as SearchKeyword
# Create the long and short range (in days) for the trend calculation.
# See the explanation in the blog for the proper use of these values.
# SET (short, long) = (5,14)-- any number
# Create dataset with all onsite searches based on unique visitors and keyword+date
# Only picking up words that do not contain other values then text or only numbers
WITH
preselect AS (
SELECT