Google Analytics 4 ব্যবহারকারী-ডেটা এক্সপোর্টের জন্য প্রশ্ন

এই পৃষ্ঠার নমুনা প্রশ্নগুলি Google Analytics 4-এর জন্য BigQuery ব্যবহারকারী-ডাটা রপ্তানির ক্ষেত্রে প্রযোজ্য। BigQuery ব্যবহারকারী-ডেটা এক্সপোর্ট প্রতিটি দিনের জন্য দুটি টেবিল তৈরি করে:

  1. একটি users_YYYYMMDD টেবিল, যা পরিবর্তিত প্রতিটি ব্যবহারকারী আইডির জন্য একটি সারি ধারণ করে৷
  2. একটি pseudonymous_users_YYYYMMDD টেবিল, যা পরিবর্তিত প্রতিটি ছদ্মনাম শনাক্তকারীর জন্য একটি সারি ধারণ করে।

আরও বিশদ বিবরণের জন্য BigQuery এক্সপোর্ট ব্যবহারকারী-ডেটা স্কিমা দেখুন।

একটি নির্দিষ্ট তারিখ ব্যাপ্তি জিজ্ঞাসা করুন

একটি BigQuery ব্যবহারকারী-ডেটা এক্সপোর্ট ডেটাসেট থেকে একটি নির্দিষ্ট তারিখের ব্যাপ্তি জিজ্ঞাসা করতে, আপনার ক্যোয়ারীটির WHERE ক্লজে _TABLE_SUFFIX ছদ্ম কলামটি ব্যবহার করুন।

উদাহরণস্বরূপ, নিম্নলিখিত ক্যোয়ারীটি 1 আগস্ট, 2023 এবং 15 আগস্ট, 2023 এর মধ্যে কমপক্ষে পাঁচ মিনিটের আজীবন ব্যস্ততার সাথে আপডেট হওয়া অনন্য ব্যবহারকারীর সংখ্যা গণনা করে।

ব্যবহারকারীদের

-- Example: Query a specific date range for users meeting a lifetime engagement criterion.
--
-- Counts unique users that are in the BigQuery user-data exports for a specific date range and have
-- a lifetime engagement of 5 minutes or more.

SELECT
  COUNT(DISTINCT user_id) AS user_count
FROM
  -- Uses a table suffix wildcard to define the set of daily tables to query.
  `PROJECT_ID.analytics_PROPERTY_ID.users_202308*`
WHERE
  -- Filters to users updated between August 1 and August 15.
  _TABLE_SUFFIX BETWEEN '01' AND '15'
  -- Filters by users who have a lifetime engagement of 5 minutes or more.
  AND user_ltv.engagement_time_millis >= 5 * 60 * 1000;

pseudonymous_users

-- Example: Query a specific date range for users meeting a lifetime engagement criterion.
--
-- Counts unique pseudonymous users that are in the BigQuery user-data exports for a specific date
-- range and have a lifetime engagement of 5 minutes or more.

SELECT
  COUNT(DISTINCT pseudo_user_id) AS pseudo_user_count
FROM
  -- Uses a table suffix wildcard to define the set of daily tables to query.
  `PROJECT_ID.analytics_PROPERTY_ID.pseudonymous_users_202308*`
WHERE
  -- Filters to users updated between August 1 and August 15.
  _TABLE_SUFFIX BETWEEN '01' AND '15'
  -- Filters by users who have a lifetime engagement of 5 minutes or more.
  AND user_ltv.engagement_time_millis >= 5 * 60 * 1000;

প্রতিটি উদাহরণ দুটি বৈশিষ্ট্য ব্যবহার করে 1 আগস্ট, 2023 থেকে 15 আগস্ট, 2023 পর্যন্ত ডেটা সীমাবদ্ধ করে:

  1. FROM ধারায় ওয়াইল্ডকার্ড 202308*
  2. WHERE ক্লজে একটি _TABLE_SUFFIX শর্ত যা টেবিলের নামের ওয়াইল্ডকার্ড অংশের উপর ভিত্তি করে টেবিল ফিল্টার করে। 202308* এর ওয়াইল্ডকার্ডের জন্য, ওয়াইল্ডকার্ডের অংশটি হল মাসের দিন।

আপনি একাধিক মাসের ডেটা জিজ্ঞাসা করার জন্য একই পদ্ধতি ব্যবহার করতে পারেন। উদাহরণস্বরূপ, 2023 সালের জানুয়ারি থেকে অক্টোবর পর্যন্ত অনুসন্ধান করতে, ক্যোয়ারীটি এতে পরিবর্তন করুন:

  1. ওয়াইল্ডকার্ড 2023*
  2. _TABLE_SUFFIX BETWEEN '0101' AND '1031' এর একটি _TABLE_SUFFIX শর্ত।

আপনি একাধিক বছরের ডেটা জিজ্ঞাসা করতে পারেন। উদাহরণস্বরূপ, অক্টোবর 2022 থেকে ফেব্রুয়ারী 2023 পর্যন্ত অনুসন্ধান করতে, ক্যোয়ারীটি এতে পরিবর্তন করুন:

  1. ওয়াইল্ডকার্ড 202*
  2. _TABLE_SUFFIX BETWEEN '21001' AND '30331' এর একটি _TABLE_SUFFIX শর্ত।

সাম্প্রতিক ব্যবহারকারী সম্পত্তি পরিবর্তনের জন্য ব্যবহারকারী আইডি

নিম্নলিখিত ক্যোয়ারীটি দেখায় যে কিভাবে user_id এবং pseudo_user_id পুনরুদ্ধার করা যায় যারা সম্প্রতি একটি নির্দিষ্ট ব্যবহারকারীর সম্পত্তি পরিবর্তন করেছেন।

ব্যবহারকারীদের

-- Example: Get the list of user_ids with recent changes to a specific user property.
DECLARE
  UPDATE_LOWER_BOUND_MICROS INT64;

-- Replace timezone. List at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
DECLARE
  REPORTING_TIMEZONE STRING DEFAULT 'America/Los_Angeles';

-- Sets the variable for the earliest update time to include. This comes after setting
-- the REPORTING_TIMEZONE so this expression can use that variable.
SET UPDATE_LOWER_BOUND_MICROS = UNIX_MICROS(
    TIMESTAMP_SUB(
      TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY, REPORTING_TIMEZONE),
      INTERVAL 14 DAY));

-- Selects users with changes to a specific user property since the lower bound.
SELECT
  users.user_id,
  FORMAT_TIMESTAMP('%F %T',
    TIMESTAMP_MICROS(
      MAX(properties.value.set_timestamp_micros)),
      REPORTING_TIMEZONE) AS max_set_timestamp
FROM
  -- Uses a table prefix to scan all data for 2023. Update the prefix as needed to query a different
  -- date range.
  `PROJECT_ID.analytics_PROPERTY_ID.users_2023*` AS users,
  users.user_properties properties
WHERE
  properties.value.user_property_name = 'job_function'
  AND properties.value.set_timestamp_micros >= UPDATE_LOWER_BOUND_MICROS
GROUP BY
  1;

pseudonymous_users

-- Example: Get the list of pseudo_user_ids with recent changes to a specific user property.
DECLARE
  UPDATE_LOWER_BOUND_MICROS INT64;

-- Replace timezone. List at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
DECLARE
  REPORTING_TIMEZONE STRING DEFAULT 'America/Los_Angeles';

-- Sets the variable for the earliest update time to include. This comes after setting
-- the REPORTING_TIMEZONE so this expression can use that variable.
SET UPDATE_LOWER_BOUND_MICROS = UNIX_MICROS(
    TIMESTAMP_SUB(
      TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY, REPORTING_TIMEZONE),
      INTERVAL 14 DAY));

-- Selects users with changes to a specific user property since the lower bound.
SELECT
  users.pseudo_user_id,
  FORMAT_TIMESTAMP('%F %T',
    TIMESTAMP_MICROS(
      MAX(properties.value.set_timestamp_micros)),
      REPORTING_TIMEZONE) AS max_set_timestamp
FROM
  -- Uses a table prefix to scan all data for 2023. Update the prefix as needed to query a different
  -- date range.
  `PROJECT_ID.analytics_PROPERTY_ID.pseudonymous_users_2023*` AS users,
  users.user_properties properties
WHERE
  properties.value.user_property_name = 'job_function'
  AND properties.value.set_timestamp_micros >= UPDATE_LOWER_BOUND_MICROS
GROUP BY
  1;

আপডেটের সারাংশ

ব্যবহারকারী-ডেটা রপ্তানি কেন ব্যবহারকারীদের বিভিন্ন বিভাগ অন্তর্ভুক্ত বা বাদ দিয়েছে তা বোঝার জন্য এই ক্যোয়ারীটি ব্যবহার করুন।

ব্যবহারকারীদের

-- Summarizes data by change type.

-- Defines the export date to query. This must match the table suffix in the FROM
-- clause below.
DECLARE EXPORT_DATE DATE DEFAULT DATE(2023,6,16);

-- Creates a temporary function that will return true if a timestamp (in micros) is for the same
-- date as the specified day value.
CREATE TEMP FUNCTION WithinDay(ts_micros INT64, day_value DATE)
AS (
  (ts_micros IS NOT NULL) AND
  -- Change the timezone to your property's reporting time zone.
  -- List at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
  (DATE(TIMESTAMP_MICROS(ts_micros), 'America/Los_Angeles') = day_value)
);

-- Creates a temporary function that will return true if a date string in 'YYYYMMDD' format is
-- for the same date as the specified day value.
CREATE TEMP FUNCTION SameDate(date_string STRING, day_value DATE)
AS (
  (date_string IS NOT NULL) AND
  (PARSE_DATE('%Y%m%d', date_string) = day_value)
);

WITH change_types AS (
SELECT user_id,
  WithinDay(user_info.last_active_timestamp_micros, EXPORT_DATE) AS user_activity,
  WithinDay(user_info.user_first_touch_timestamp_micros, EXPORT_DATE) AS first_touch,
  SameDate(user_info.first_purchase_date, EXPORT_DATE) as first_purchase,
  (EXISTS (SELECT 1 FROM UNNEST(audiences) AS aud
           WHERE WithinDay(aud.membership_start_timestamp_micros, EXPORT_DATE))) AS audience_add,
  (EXISTS (SELECT 1 FROM UNNEST(audiences) AS aud
           WHERE WithinDay(aud.membership_expiry_timestamp_micros, EXPORT_DATE))) AS audience_remove,
  (EXISTS (SELECT 1 FROM UNNEST(user_properties) AS prop
           WHERE WithinDay(prop.value.set_timestamp_micros, EXPORT_DATE))) AS user_property_change
FROM
  -- The table suffix must match the date used to define EXPORT_DATE above.
  `project_id.analytics_property_id.users_20230616`
)
SELECT
  user_activity,
  first_touch,
  first_purchase,
  audience_add,
  audience_remove,
  user_property_change,
  -- This field will be true if there are no changes for the other change types.
  NOT (user_activity OR first_touch OR audience_add OR audience_remove OR user_property_change) AS other_change,
  COUNT(DISTINCT user_id) AS user_id_count
FROM change_types
GROUP BY 1,2,3,4,5,6,7;

pseudonymous_users

-- Summarizes data by change type.

-- Defines the export date to query. This must match the table suffix in the FROM
-- clause below.
DECLARE EXPORT_DATE DATE DEFAULT DATE(2023,6,16);

-- Creates a temporary function that will return true if a timestamp (in micros) is for the same
-- date as the specified day value.
CREATE TEMP FUNCTION WithinDay(ts_micros INT64, day_value DATE)
AS (
  (ts_micros IS NOT NULL) AND
  -- Change the timezone to your property's reporting time zone.
  -- List at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
  (DATE(TIMESTAMP_MICROS(ts_micros), 'America/Los_Angeles') = day_value)
);

-- Creates a temporary function that will return true if a date string in 'YYYYMMDD' format is
-- for the same date as the specified day value.
CREATE TEMP FUNCTION SameDate(date_string STRING, day_value DATE)
AS (
  (date_string IS NOT NULL) AND
  (PARSE_DATE('%Y%m%d', date_string) = day_value)
);

WITH change_types AS (
SELECT pseudo_user_id,
  WithinDay(user_info.last_active_timestamp_micros, EXPORT_DATE) AS user_activity,
  WithinDay(user_info.user_first_touch_timestamp_micros, EXPORT_DATE) AS first_touch,
  SameDate(user_info.first_purchase_date, EXPORT_DATE) as first_purchase,
  (EXISTS (SELECT 1 FROM UNNEST(audiences) AS aud
           WHERE WithinDay(aud.membership_start_timestamp_micros, EXPORT_DATE))) AS audience_add,
  (EXISTS (SELECT 1 FROM UNNEST(audiences) AS aud
           WHERE WithinDay(aud.membership_expiry_timestamp_micros, EXPORT_DATE))) AS audience_remove,
  (EXISTS (SELECT 1 FROM UNNEST(user_properties) AS prop
           WHERE WithinDay(prop.value.set_timestamp_micros, EXPORT_DATE))) AS user_property_change
FROM
  -- The table suffix must match the date used to define EXPORT_DATE above.
  `PROJECT_ID.analytics_PROPERTY_ID.pseudonymous_users_20230616`
)
SELECT
  user_activity,
  first_touch,
  first_purchase,
  audience_add,
  audience_remove,
  user_property_change,
  -- This field will be true if there are no changes for the other change types.
  NOT (user_activity OR first_touch OR audience_add OR audience_remove OR user_property_change) AS other_change,
  COUNT(DISTINCT pseudo_user_id) pseudo_user_id_count
FROM change_types
GROUP BY 1,2,3,4,5,6,7;