Skip to content

Commit

Permalink
Add conversion rate column
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeelaudibert committed Dec 3, 2024
1 parent 1e8365e commit f70dcdb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions posthog/hogql_queries/web_analytics/stats_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,20 @@ def calculate(self):
else response.columns
)

# Add last conversion rate column
if self.query.conversionGoal is not None:
unique_visitors = results_mapped[0]
unique_conversions = results_mapped[-1]

# Keep them in the same tuple format we already have
results_mapped.append(
(
unique_conversions[0] / unique_visitors[0] if unique_visitors[0] != 0 else None,
unique_conversions[1] / unique_visitors[1] if unique_visitors[1] != 0 else None,
)
)
columns.append("context.columns.conversion_rate")

Check failure on line 541 in posthog/hogql_queries/web_analytics/stats_table.py

View workflow job for this annotation

GitHub Actions / Python code quality checks

Item "None" of "list[Any] | None" has no attribute "append"

return WebStatsTableQueryResponse(
columns=columns,
results=results_mapped,
Expand Down

0 comments on commit f70dcdb

Please sign in to comment.