<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muslikh Annur on Medium]]></title>
        <description><![CDATA[Stories by Muslikh Annur on Medium]]></description>
        <link>https://medium.com/@muslikhannur?source=rss-f99ef036cf02------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Muslikh Annur on Medium</title>
            <link>https://medium.com/@muslikhannur?source=rss-f99ef036cf02------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:02:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muslikhannur/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Crafting a Maintainable Query]]></title>
            <link>https://medium.com/stockbit-bibit-engineering/crafting-a-maintainable-query-3dbd271f8403?source=rss-f99ef036cf02------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dbd271f8403</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[query]]></category>
            <dc:creator><![CDATA[Muslikh Annur]]></dc:creator>
            <pubDate>Thu, 23 Nov 2023 06:12:25 GMT</pubDate>
            <atom:updated>2023-11-23T06:12:25.268Z</atom:updated>
            <content:encoded><![CDATA[<p>In my journey through the data field over the past three years, I’ve gained a lot of insights and honed my data-wrangling and problem-solving skills. My latest adventure has led me to a leading fintech company, where I’ve spent the last year working with a diverse team of data professionals. This team boasts an array of talents and responsibilities, from Data Analysts to Business Intelligence, Data Engineers, and even Data Scientists.</p><h3>The Shared Query Dilemma</h3><p>As someone who shares SQL queries for various purposes, such as creating dashboard data sources and establishing single sources of truth, query management has become a concern for me. As the team continues to grow, the ability to create and maintain collaboration-friendly queries has become not just a preference but a necessity to save our resources.</p><p>For me, collaboration-friendly queries must possess three core principles: <strong>descriptive, neat, and efficient</strong>. While some of these principles appear simple and straightforward, it’s astonishing how frequently it overlooked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdG1zO2g06HVkByPdyTXzg.png" /></figure><p>Here’s an outline for each principle</p><ul><li><strong>Descriptive</strong><br>- Define Clear Identifiers<br>- Avoid Reserved Keywords<br>- Add Informative Comments</li><li><strong>Neat</strong><br>- Maintain Consistent Naming Convention<br>- Implement Proper Indentation<br>- Pay Attention to Letter Case</li><li><strong>Efficient</strong><br>- Utilize Common Table Expressions (CTEs)<br>- Avoid Using SELECT *<br>- Know When (not) to Aggregate</li></ul><p>Let’s explore each principle in detail. The examples (from less to more optimal queries) may seem basic, but as cases become more complex, following these guidelines becomes essential for easy maintenance.</p><p>Note that these examples are in BigQuery dialect. Different databases may have slight variations in SQL, including query conventions (e.g. BigQuery required you to use dataset_id.table_id in their FROM clause due to its hierarchical structure to organize data) and some clause differences despite referring to the same function. These principles are versatile but should be applied with consideration for your chosen database.</p><h3>Descriptive Queries</h3><p>Remember that clarity is key. Everything you write should leave a clear impression because you’re not working alone in this journey of data.</p><h4>— Define Clear Identifiers</h4><p>Choosing name identifiers like column aliases, and common table expressions (CTEs) is essential. Avoid vague aliases like a, b, or x. Especially in CTE or subqueries that contain complex mechanics of data retrieval. Imagine someone spent a long time understanding your complex query yet still forgot what all those vague aliases refer to. Sigh.</p><pre><br>-- Before<br><br>WITH<br>p AS (<br>  SELECT<br>    o.transaction_id AS a,<br>    o.transaction_date AS b,<br>    p.product_name AS c, <br>    o.quantity AS d<br>  FROM `Transactions.fact_transactions` o<br>  JOIN `Transactions.dim_products` p <br>    ON o.product_id = p.id<br>)<br><br>SELECT<br>  a AS transaction_id,<br>  b AS transaction_date,<br>  c AS product_name,<br>  SUM(d) AS total_quantity<br>FROM p<br>GROUP BY a, b, c<br>HAVING SUM(d) &gt; 10</pre><pre>-- After<br><br>WITH<br>transaction_details_cte AS (<br>  SELECT<br>    o.transaction_id,<br>    o.transaction_date,<br>    p.product_name,<br>    o.quantity,<br>  FROM `Transactions.fact_transactions` o<br>  JOIN `Transactions.dim_products` p <br>    ON o.product_id = p.product_id<br>)<br><br>SELECT<br>    transaction_id,<br>    transaction_date,<br>    product_name,<br>    SUM(quantity) AS total_quantity<br>FROM transaction_details_cte<br>GROUP BY transaction_id, transaction_date, product_name<br>HAVING SUM(quantity) &gt; 10</pre><h4>— Avoid Reserved Keywords</h4><p>Steer clear of identifiers that might be mistaken for SQL keywords, like value or date. This practice can lead to cognitive load be it confusion or even reduced readability. It’s important to note that SQL editors often format reserved keywords that are visually distinct.</p><pre>-- Before<br><br>WITH <br>value AS (<br>  SELECT <br>    transaction_date date, <br>    user_id, <br>    COUNT(1) cnt_transaction<br>  FROM `Transactions.fact_transactions`<br>  GROUP BY transaction_date, user_id<br>)<br><br>SELECT<br>  date, <br>  AVG(cnt_transaction) avg_transaction_per_user<br>FROM value<br>GROUP BY date</pre><pre>-- After<br><br>WITH <br>daily_order_by_user AS (<br>  SELECT <br>    transaction_date, <br>    user_id, <br>    COUNT(1) cnt_transaction<br>  FROM `Transactions.fact_transactions`<br>  GROUP BY transaction_date, user_id<br>)<br><br>SELECT<br>  transaction_date, <br>  AVG(transaction_count) avg_transaction_per_user<br>FROM daily_order_by_user<br>GROUP BY transaction_date</pre><p>Reserved keywords as identifiers also can result in errors. For instance, if you want to flag ‘Store’ as the transaction source in a column called <em>from</em>, the first example would cause an error. To mitigate this issue, the second example avoids errors by enclosing the reserved keyword in backticks. However, it’s generally advised to choose non-reserved words for identifiers to enhance code readability and maintainability.</p><pre>-- Before<br><br>SELECT transaction_amount, &#39;Store&#39; from<br>FROM `Transactions.fact_transactions`</pre><pre>-- After<br><br>SELECT transaction_amount, &#39;Store&#39; `from`<br>FROM `Transactions.fact_transactions`</pre><h4>— Add Informative Comments</h4><p>Comments in your queries provide valuable context. Explain the query’s purpose, any unique logic, or potential optimizations through comments. Treat comments as guideposts for yourself and your team. They clarify the query’s intent, making it easier to understand and maintain.</p><pre>-- Before<br><br>-- Retrieve user status based on TPV over time.<br>WITH<br>flagging (<br>  SELECT <br>    user_id,<br>    history_date,<br>    CASE <br>      WHEN cummulative_tpv &gt;= 100000000 THEN &#39;High Value Users&#39;<br>      WHEN cummulative_tpv &gt;= 50000000 AND week_num &lt;= 2 THEN &#39;Potential Users&#39;<br>    END user_status<br>  FROM `Transactions.fact_users_tpv_history`<br>)<br><br>SELECT * EXCEPT(user_status),<br>  IFNULL(<br>    IFNULL(<br>      LAST_VALUE(affluent_flag IGNORE NULLS) OVER (PARTITION BY user_id ORDER BY date ), user_status<br>    ), &#39;Mass Users&#39;<br>  ) user_status<br>FROM flagging</pre><pre>-- After<br><br>WITH<br>flagging (<br>  -- Flag status based on TPV over time. NULL results still possible.<br>  SELECT <br>    user_id,<br>    history_date,<br>    CASE <br>      WHEN cummulative_tpv &gt;= 100000000 THEN &#39;High Value Users&#39;<br>      WHEN cummulative_tpv &gt;= 50000000 AND week_num &lt;= 2 THEN &#39;Potential Users&#39;<br>    END user_status<br>  FROM `Transactions.fact_users_tpv_history`<br>)<br><br>-- Fill NULL based on user latest status. If still NULL flag as &#39;Mass Users&#39;.<br>SELECT * EXCEPT(user_status),<br>  IFNULL(<br>    IFNULL(<br>      LAST_VALUE(affluent_flag IGNORE NULLS) OVER (PARTITION BY user_id ORDER BY date), user_status<br>    ), &#39;Mass Users&#39;<br>  ) user_status<br>FROM flagging</pre><h3>Neat Queries</h3><p>Moving beyond clarity, let’s delve into the aspect of query aesthetics.</p><h4>— Maintain Consistent Naming Convention</h4><p>Consider not only the descriptive nature of your identifiers but also the consistency in how you name them. Instead of merely focusing on giving identifiers clear names, it’s equally important to adhere to a consistent naming convention that signifies context and organization.</p><p>For example, <em>[aggregation type]_[business entity]_[attribute value]</em>, if you have a column convention like that then be consistent to use that for the other column. Maintaining a naming convention indirectly enhances visual cues, as some of the BI tools often automatically sort the column. Not to mention that using this approach by giving prefix or suffix also give the reader more context about your table and column.</p><pre>-- Before<br><br>SELECT  <br>  p.product_name AS name,<br>  SUM(o.transaction_amount) AS revenue, <br>  AVG(o.quantity) AS avg_quantity<br>FROM `Transactions.fact_transactions` o<br>JOIN `Transactions.dim_products` p <br>  ON o.product_id = p.id<br>GROUP BY product_name</pre><pre>-- After<br><br>SELECT <br>  p.product_name,<br>  SUM(o.transaction_amount) AS total_product_revenue,<br>  AVG(o.quantity) AS avg_product_purchase_qty<br>FROM `Transactions.fact_transactions` o<br>JOIN `Transactions.dim_products` p <br>  ON o.product_id = p.id<br>GROUP BY product_name</pre><h4>— Implement Proper Indentation</h4><p>Utilize whitespace to separate different parts of your query. Strike a balance between vertical spacing and readability. Proper indentation enhances the visual appeal of your SQL code and helps readers follow the logical structure of the query. It’s crucial to know when to enter a new line and when not to, maintaining a consistent style for readability.</p><pre>-- Before<br><br>WITH <br>latest_placement AS (<br>SELECT<br>employee_id,<br>placement<br>FROM `Company.fact_employees_placement_history`<br>QUALIFY ROW_NUMBER() OVER(PARTITION BY employee_id ORDER BY work_date DESC) = 1<br>)<br><br>SELECT<br>employee_id,<br>employee_name,<br>placement<br>CASE  <br>  WHEN hire_date &gt;= &#39;2023-01-01&#39; THEN<br>  CASE WHEN department = &#39;HR&#39; THEN &#39;New HR Employee&#39;<br>      WHEN department = &#39;Finance&#39; THEN &#39;New Finance Employee&#39;<br>      ELSE &#39;New Employee in Other Department&#39;<br>      END<br>  WHEN hire_date &gt;= &#39;2022-01-01&#39; THEN<br>  CASE WHEN department = &#39;HR&#39; THEN &#39;Experienced HR Employee&#39;<br>      WHEN department = &#39;Finance&#39; THEN &#39;Experienced Finance Employee&#39;<br>      ELSE &#39;Experienced Employee in Other Department&#39;<br>      END<br>  ELSE &#39;Employee Hired in 2022&#39;<br>END AS employee_status<br>FROM `Company.dim_employees`<br>LEFT JOIN latest_placement<br>  USING (employee_id)</pre><pre>-- After<br><br>WITH <br>latest_placement AS (<br>  SELECT<br>    employee_id,<br>    placement<br>  FROM `Company.fact_employees_placement_history`<br>  QUALIFY ROW_NUMBER() OVER(PARTITION BY employee_id ORDER BY work_date DESC) = 1<br>)<br><br>SELECT<br>  employee_id,<br>  employee_name,<br>  placement,<br>  CASE <br>    WHEN hire_date &gt;= &#39;2023-01-01&#39; THEN<br>      CASE<br>        WHEN department = &#39;HR&#39; THEN &#39;New HR Employee&#39;<br>        WHEN department = &#39;Finance&#39; THEN &#39;New Finance Employee&#39;<br>        ELSE &#39;New Employee in Other Department&#39;<br>      END<br>    WHEN hire_date &gt;= &#39;2022-01-01&#39; THEN<br>      CASE<br>        WHEN department = &#39;HR&#39; THEN &#39;Experienced HR Employee&#39;<br>        WHEN department = &#39;Finance&#39; THEN &#39;Experienced Finance Employee&#39;<br>        ELSE &#39;Experienced Employee in Other Department&#39;<br>      END<br>    ELSE &#39;Employee Hired in 2022&#39;<br>  END AS employee_status<br>FROM `Company.dim_employees`<br>LEFT JOIN latest_placement<br>  USING (employee_id)</pre><p>The first example has some indentation to make it more readable, but it’s not as tidy or consistent as the second example. Proper indentation is essential for code maintainability, particularly in scenarios involving nested elements like nested conditional expressions or nested queries (either CTEs or subqueries), so it’s recommended to follow the best practices demonstrated in the second example whenever possible.</p><h4>— Pay Attention to Letter Case</h4><p>Distinguish SQL keywords (typically <em>UPPERCASE</em>) from custom identifier names (typically a <em>snake_case</em>). Adhering to a consistent letter case convention improves query aesthetics and readability by making it easier to differentiate between SQL keywords and custom identifiers.</p><pre>-- Before<br><br>select <br>  employee_id, <br>  Employee_Name, <br>  SUM(Salary) as TotalSalary<br>from `Company.dim_employees`<br>where EmploymentStatus = &#39;active&#39;<br>group by Department</pre><pre>-- After<br><br>SELECT <br>  employee_id, <br>  employee_name, <br>  SUM(salary) AS total_salary<br>FROM `Company.dim_employees`<br>WHERE employment_status = &#39;active&#39;<br>GROUP BY department</pre><h3>Efficient Queries</h3><p>The focus of this part is not primarily centered on memory optimization but rather on enhancing the efficiency of query creation, comprehension, and maintenance. However, it’s worth noting that the chosen approach may also have an impact on memory optimization to some extent.</p><h4>— Utilize Common Table Expressions (CTEs)</h4><p>Enforce the <em>“Don’t Repeat Yourself”</em> (DRY) principle by using CTEs. Isolating subqueries in CTEs not only enhances query maintainability but also enhances query readability, making them easier to manage.</p><pre><br>-- Before<br><br>SELECT <br>  transaction_date event_date, <br>  &#39;transaction&#39; event_name, <br>  COUNT(1) count_event<br>FROM `Transactions.fact_transactions`<br>WHERE transaction_date IN (<br>  SELECT calendar_date<br>  FROM `Transactions.fact_trade_day`<br>  WHERE is_trade_day = 1<br>    AND calendar_date BETWEEN DATE_TRUNC(CURRENT_DATE(), YEAR) AND CURRENT_DATE()-1<br>)<br>GROUP BY 1,2<br><br>UNION ALL<br>SELECT <br>  event_date, <br>  event_name, <br>  COUNT(1) count_event<br>FROM `Events.event_open_app`<br>WHERE event_date IN (<br>  SELECT calendar_date<br>  FROM `Transactions.fact_trade_day`<br>  WHERE is_trade_day = 1<br>    AND calendar_date BETWEEN DATE_TRUNC(CURRENT_DATE(), YEAR) AND CURRENT_DATE()-1<br>)<br>GROUP BY 1,2</pre><pre>-- After<br><br>WITH<br>trade_day_current_year AS (<br>  SELECT calendar_date<br>  FROM `Transactions.fact_trade_day`<br>  WHERE is_trade_day = 1<br>    AND calendar_date BETWEEN DATE_TRUNC(CURRENT_DATE(), YEAR) AND CURRENT_DATE()-1<br>)<br><br>SELECT <br>  transaction_date event_date, <br>  &#39;transaction&#39; event_name, <br>  COUNT(1) count_event<br>FROM `Transactions.fact_transactions`<br>WHERE transaction_date IN (SELECT * trade_day_current_year)<br>GROUP BY 1,2<br>UNION ALL<br>SELECT <br>  event_date, <br>  event_name, <br>  COUNT(1) count_event<br>FROM `Events.event_open_app`<br>WHERE event_date IN (SELECT * trade_day_current_year)<br>GROUP BY 1,2</pre><p>Also, think about making use of CTEs to segregate the query sections that need to be executed initially at the top. This approach aligns with the way humans naturally read, which typically begins with the top sections. This not only reduces the time and cognitive load required for locating the starting point but also enhances overall readability.</p><pre>-- Before<br><br>WITH <br>employees_with_salaries AS (<br>  SELECT E.employee_id, E.first_name, E.last_name, S.salary<br>  FROM `Company.dim_employees` E<br>  JOIN `Company.fact_salaries` S S <br>    ON E.employee_id = S.employee_id<br>),<br>employee_years_of_service AS (<br>  SELECT E.employee_id, DATEDIFF(YEAR, E.join_date, GETDATE()) AS years_of_service<br>  FROM `Company.dim_employees` E<br>),<br>high_paying_employees AS (<br>  SELECT E.employee_id, E.first_name, E.last_name<br>  FROM employees_with_salaries E<br>  WHERE E.salary &gt; 80000<br>),<br>experienced_high_paying_employees AS (<br>  SELECT E.employee_id, E.first_name, E.last_name, EYS.years_of_service<br>  FROM high_paying_employees E<br>  JOIN employee_years_of_service EYS <br>    ON E.employee_id = EYS.employee_id<br>)<br><br>SELECT E.first_name, E.last_name, E.years_of_service<br>FROM experienced_high_paying_employees E<br>WHERE E.years_of_service &gt;= 5</pre><pre>-- After<br><br>WITH <br>employee_years_of_service AS (<br>  SELECT E.employee_id, DATEDIFF(YEAR, E.join_date, GETDATE()) AS years_of_service<br>  FROM `Company.dim_employees` E<br>),<br>employees_with_salaries AS (<br>  SELECT E.employee_id, E.first_name, E.last_name, S.salary<br>  FROM `Company.dim_employees` E<br>  JOIN `Company.fact_salaries` S <br>    ON E.employee_id = S.employee_id<br>),<br>high_paying_employees AS (<br>  SELECT E.employee_id, E.first_name, E.last_name<br>  FROM employees_with_salaries E<br>  WHERE E.salary &gt; 80000<br>),<br>experienced_high_paying_employees AS (<br>  SELECT E.employee_id, E.first_name, E.last_name, EYS.years_of_service<br>  FROM high_paying_employees E<br>  JOIN employee_years_of_service EYS <br>    ON E.employee_id = EYS.employee_id<br>)<br><br>SELECT E.first_name, E.last_name, E.years_of_service<br>FROM experienced_high_paying_employees E<br>WHERE E.years_of_service &gt;= 5;</pre><p>In the second example, the CTEs are ordered in a way that reflects their logical usage in the final query, making it easier to follow the flow of the query and understand the relationships between them.</p><h4>— Avoid Using SELECT *</h4><p>Specify the columns you need. AvoidingSELECT * will reduce memory usage and execution time, making your queries more efficient.</p><pre>-- Before<br><br>SELECT * <br>FROM `Company.dim_employees`<br>WHERE department = &#39;HR&#39;</pre><pre>-- After<br><br>SELECT employee_id, first_name, last_name<br>FROM `Company.dim_employees`<br>WHERE department = &#39;HR&#39;</pre><p>Also, it will cost you time if you put SELECT * questions in CTEs when you need to do column selection later or track the origin of a certain column.</p><h4>— Know When (not) to Aggregate</h4><p>I once inherited a dashboard project from a friend, and I discovered it had a rigid query structure. He used an aggregated schema with pivots for each attribute. The problem arose when users frequently requested additional attributes as dashboard filters. This meant I had to create a pivot column for each combination of distinct values from different attributes.</p><p>Not only was this query hard to maintain, but it also caused extra steps in BI tools like Tableau. When you intend to use attributes from a pivoted-aggregated view as filters, you’re forced to create parameters. In contrast, attributes that are left as attributes can be used as filters directly.</p><p>Suppose you have commerce data that allows users to buy and sell, consider consolidating buy and sell amounts into a single attribute. Similarly, you can leave the category as is, without the need for pivoting where you can do that on BI tools. Here’s a more concise approach:</p><pre>-- Before<br><br>SELECT <br>  transaction_date, <br>  user_id,<br>  SUM(CASE WHEN category = &#39;Bills&#39; THEN amount_buy END) amount_buy_bills<br>  SUM(CASE WHEN category = &#39;Foods&#39; THEN amount_buy END) amount_buy_foods<br>  SUM(CASE WHEN category = &#39;Fashions&#39; THEN amount_buy END) amount_buy_fashions<br>  SUM(CASE WHEN category = &#39;Bills&#39; THEN amount_sell END) amount_sell_bills<br>  SUM(CASE WHEN category = &#39;Foods&#39; THEN amount_sell END) amount_value_sell_foods<br>  SUM(CASE WHEN category = &#39;Fashions&#39; THEN amount_sell END) amount_value_sell_fashions<br>FROM `Transactions.fact_transactions`<br>GROUP BY transaction_date, user_id</pre><pre>-- After<br><br>SELECT <br>  transaction_date, <br>  user_id, <br>  category, <br>  &#39;Buy&#39; transaction_type, <br>  amount_buy amount<br>FROM `Transactions.fact_transactions`<br><br>UNION ALL<br>SELECT <br>  transaction_date, <br>  user_id, <br>  category, <br>  &#39;Sell&#39; transaction_type, <br>  amount_sell amount<br>FROM `Transactions.fact_transactions`</pre><p>Review whether the query is intended for a long-term project like the view you create for your monitoring dashboard or just a one-time report.</p><ul><li><strong>Create a raw view</strong> for situations that demand quick adaptability as requirements grow. For instance, when users ask for additional filtering attributes, this approach allows aggregation operations managed within the BI tool, eliminating the repetitive aggregation queries.</li><li>In contrast, <strong>establish an aggregated view</strong> when dealing with one-time reports or dashboards that don’t require ongoing updates.</li></ul><h3>Beyond Code Quality</h3><p>I once mentioned that the ability to create and maintain collaboration-friendly queries has become not just a preference but a necessity. While these ‘formatting’ guidelines might not have any bearing on the compiler, their significance goes beyond preserving code quality; they serve as a tangible display of your respect for your teammates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dbd271f8403" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stockbit-bibit-engineering/crafting-a-maintainable-query-3dbd271f8403">Crafting a Maintainable Query</a> was originally published in <a href="https://medium.com/stockbit-bibit-engineering">Stockbit-Bibit Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Data Tracking Matters for a Product]]></title>
            <link>https://medium.com/gdplabs/why-data-tracking-matters-for-a-product-e8efac107b4b?source=rss-f99ef036cf02------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8efac107b4b</guid>
            <category><![CDATA[product-management]]></category>
            <category><![CDATA[data-tracking]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <dc:creator><![CDATA[Muslikh Annur]]></dc:creator>
            <pubDate>Thu, 28 Apr 2022 05:34:12 GMT</pubDate>
            <atom:updated>2023-10-01T10:31:46.861Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“Sometimes it’s the journey that teaches you a lot about your destination.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*24cOD8SDMc4nL6Ak" /><figcaption>Photo by <a href="https://unsplash.com/@soymeraki">Javier Allegue Barros</a> on <a href="https://unsplash.com/photos/C7B-ExXpOIE">Unsplash</a></figcaption></figure><p>It’s almost one year and a half since I joined GDP Labs as a Data Analyst, which is also my first job after graduating from college. There are a lot of things I did (and learned, sure) since day one. I was assigned to one of GDP Labs sister company, <a href="https://www.kaskus.co.id/">Kaskus</a>, the Largest Indonesian Community Platform.</p><h3>What I actually did and what this article covers</h3><p>In terms of what I did, just as you imagine about Data Analyst, the day-to-day task is to play around with raw data. Most of the time I‘m dealing with ad-hoc requests, sometimes dashboarding in BI tools to reduce it, and at times doing deep-dive analysis that mostly lies in descriptive and diagnostic levels.</p><p>Something that never crossed my mind is dealing with the collection of the data itself, especially collecting information on how the product behaves. We need to take care of those data so it comes in proper form before we start doing any of the tasks as I mentioned before.</p><p>I may say data is divided into two types,</p><ul><li><strong>Transactional</strong>, or the outcome-related data in a product or feature, that comes from the backend side. Like order data in eCommerce, or for instance in our case thread creation, community creation, etc.</li><li><strong>Behavioral</strong>, data tells us how users interact with a product or feature in granular detail. All of their activities belong to this part.</li></ul><p>I deal with both of them in doing my day-to-day tasks, but let’s focus on the collection of behavioral data since it takes a decent amount of my working portion even though it’s still relatively new for me.</p><h3>A brief definition</h3><p>Speaking of behavioral data itself, there comes a term called data tracking. It is a sort of activity of identifying and categorizing data points through events that happen on a product. All those event data are collected by placing a tracking code in a website or app, and it will connect to the analytics tracking application we use and could be our behavioral data source later, which at the same time could be a complement of our transactional data.</p><p>A lot of options are available when it comes to analytics tracking tools like Google Analytics, HubSpot, Mixpanel, and many more that offer you different features (and limitations as well). Here, we use Google Analytics as the main analytics tracking tool as well as the behavioral data source, which is also connected to other tools like Tag Manager (GTM) and Firebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Knr53mSOprVGJeOryVybtw.png" /><figcaption>A simple diagram of existing Data Tracking in the Kaskus Forum</figcaption></figure><p>Back to the previous data tracking definition, the output will be a data tracking documentation so we have a clear guide on which behavioral data to track for our reporting requirement as well as supporting future exploration. Mostly, the one who asks for those data is the PM and UX Designer, So as time goes by I won’t be surprised if one of them comes up with a sprint plan and ask me about the reporting requirement of the feature they plan to release which will lead me to design (or update) the documentation.</p><h3>“Unfortunately, we haven’t tracked that yet” :(</h3><p>Enough said all the theories, it won’t be really clear without a real use case. Understandable, even in the first month I don’t know the real essence of all these tracking things until I do a lot of hands-on and have some use case to deal with. This section is also the starting point of the “Why”.</p><p>Long story short, in the middle of a meeting, a new member of the product team suddenly asks, “Just out of curiosity guys, what features actually drive users to sign-up to our platform? Could it be creating a thread? or joining a community?”. Sounds like a fundamental question, maybe he wants to know what is the ‘selling point’ that makes users intend to convert. Turns out, we can’t answer it at that meeting. Hence, I highlight it as a bold subtitle above.</p><p>At that time we had no data about what drives the user to sign in or sign-up even though we tracked some of the sign-up journeys. Then we realized our sign-up journey tracking was not holistic enough, because we don’t track the top of the funnels which actually tells us more about the sign-up.</p><p>Soon after that, we track events in every entry point where it triggers the sign-in and sign-up modal. I attach a code snippet below based on that requirement, luckily the requirement isn’t that complex thus the code will be very simple as well, we don&#39;t need many parameters as a detail of the event.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05a943de7d87d3d1438857fcbce9424c/href">https://medium.com/media/05a943de7d87d3d1438857fcbce9424c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/34453441acda6efef20dc0e709cb698c/href">https://medium.com/media/34453441acda6efef20dc0e709cb698c/href</a></iframe><p>Anyway, in data tracking implementation, at least you need to define,</p><ul><li><strong>Event</strong>: a sort of user action that we want to collect. It could be a click, impression, or even a pageview. From the previous case, we can name the event pre_intent_to_sign_in that will be fired when users want to use the feature and get a sign-in modal because they are in a non-login state.</li><li><strong>Parameter</strong>: details we want to send once the event is fired. We can send it alongside the event if it happens in more than one entry point or if the event has any granular detail to drill down. Some people might refer to it as the event property. From the previous example, we can add the section_referrer parameter since the event can happen in many entry points like create thread, reply, upvote, etc. during the non-login state.</li></ul><p>If you find the code snippet on the web seems different and confusing, hold on. Basically, the tracking on the Web uses a data layer, a JavaScript object to pass information from our website to the Tag Manager container. Thus we need to map that by creating Google Analytics Tags that will send the same event and parameter value as shown below. All is set for that requirement, now we can get the information that drives users to sign-up the most.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9LDl5Xa5zUTV4IHEzKOP_g.png" /><figcaption>Event Mapping for Web from Tag Manager to Google Analytics</figcaption></figure><p>Later on, another question comes from the UX Designer, “Have you found any particular sign-up process where it seems to decrease a lot from the previous process? or maybe a process where it takes a long time to do”. <em>Sigh</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_S6wUqWXMXkysBxnMtCz9A.png" /><figcaption>What UX Designer asked about the Sign-Up process</figcaption></figure><p>Luckily we have already planned it since we took the previous lesson learned where we missed one of the funnels. Just like the previous implementation, we need to define all the events we are going to collect alongside the journey, as well as the parameters to add a better granularity of information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4uut8CGSweiPiGPinbrVew.png" /><figcaption>The compact version of Data Tracking Documentation for Sign-Up process</figcaption></figure><p>Now we have the tracking of the registration process and we can explore which process (events) is extremely decreasing and affecting overall funnels. Even better, with parameters, we can gain more specific information. For instance, later on, we find out that sign_up is decreasing and affecting the last funnels. Turns out “google”, the most used 3rd party sign-up method, has an issue by looking at how each event_method performs in sign_up.</p><p>Another question we can answer from the UX Designer is which process takes a long time for users to do in both event and parameter levels in the latest <a href="https://support.google.com/analytics/answer/9327974?hl=en">Google Analytics funnel report</a>. As shown in the illustration, we find that a particular section_referrer like “upvote” on top of the funnel doesn’t end up having a good conversion and takes a long time for users to go to the next step, then after exploring the product we found that upvote in a non-login state indeed acts differently by only showing a toast to warn people to login instead of directly showing the modal like any other entry point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2xKXiYhI4OrGUBgiBemTvA.png" /><figcaption>Sign-Up funnel drilled down by section_referrer (<em>Data are Self-created</em>)</figcaption></figure><p>That’s one of the real yet very simple cases of why we need behavioral data through data tracking. It enriches the story behind the final results of your feature. So the more features you have, the more events might need to be tracked. As long as it is important to know, go track it. As a side note, pay attention to parameters that are sent alongside the events (in terms of what kind of parameters, and how many parameters) because in some cases the query process to retrieve that parameter value could affect performance.</p><h3>Common questions Data Tracking can help</h3><p>The previous section is actually just a sort of question that is coincidentally interconnected from only one feature and I find it interesting to tell. There are a lot of other questions that make me realize the essence of data tracking and maintaining the product’s behavioral data i.e.</p><ul><li>“How many percent of users that visit this thread, then finally convert?”</li><li>“How does the behavior of creating a thread differ in Web and App?”</li><li>“Can I get section distribution where people open community the most?”</li><li>“How does our latest feature behave ya? does it affect our main metrics?”</li><li>“Is this person replying a lot in our event really active in the community by at least opening some threads and related community?”</li><li>..and many more questions require only behavioral data or even require both combinations of transactional and behavioral data.</li></ul><p>As it sounds, all those questions can come from various roles like Product Manager, UX Designer, and Software Engineer, or even from Operational Teams like Content, Marketing, and Community. Then all the answers might end up as an insight for them or even a future improvement. Up to this point, I think we all have got some idea why this is all-important.</p><h3>Recall of the “Why”</h3><p>From all previous use cases and common questions, I could say data tracking really takes a crucial part especially when a product grows even further. It gives you another reference of how users behave in a product whether it’s a journey, entry point, preference, or any granularity of the event besides only relying on the transactional data that only represents the end results.</p><p>As a new person in this field, at least I got a new lesson on how to collect data through maintaining data tracking besides wrangling data every day, though at first, I rant quite often on the old tracking documentation and implementation. Data tracking also taught me the perspective of managing a product from other people in different roles that work around me.</p><p>To end this article, I want to recall and clarify the quote in the beginning: There will come a time when it’s the ‘journey’, or behavioral data, that will teach you a lot about your ‘destination’, or main metrics you want to track mainly from transactional data. It’s a good complement after all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8efac107b4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/gdplabs/why-data-tracking-matters-for-a-product-e8efac107b4b">Why Data Tracking Matters for a Product</a> was originally published in <a href="https://medium.com/gdplabs">gdplabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>