Skip to content

Commit

Permalink
fix(cdp): add gclid fallback and warning (#25797)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarconLP authored and timgl committed Oct 25, 2024
1 parent b8252c4 commit 642a381
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion posthog/cdp/templates/google_ads/template_google_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
icon_url="/static/services/google-ads.png",
category=["Advertisement"],
hog="""
if (empty(inputs.gclid)) {
print('Empty `gclid`. Skipping...')
return
}
let res := fetch(f'https://googleads.googleapis.com/v17/customers/{replaceAll(inputs.customerId, '-', '')}:uploadClickConversions', {
'method': 'POST',
'headers': {
Expand Down Expand Up @@ -72,7 +77,7 @@
"type": "string",
"label": "Google Click ID (gclid)",
"description": "The Google click ID (gclid) associated with this conversion.",
"default": "{person.gclid}",
"default": "{person.properties.gclid ?? person.properties.$initial_gclid}",
"secret": False,
"required": True,
},
Expand Down
6 changes: 6 additions & 0 deletions posthog/cdp/templates/google_ads/test_template_google_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ def test_function_works(self):
},
)
)

def test_function_requires_identifier(self):
self.run_function(self._inputs(gclid=""))

assert not self.get_mock_fetch_calls()
assert self.get_mock_print_calls() == snapshot([("Empty `gclid`. Skipping...",)])

0 comments on commit 642a381

Please sign in to comment.