You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs-app/data/google-tag-manager/08-advanced-iframe-purchase-tracking-via-postmessage.md
+48-35Lines changed: 48 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
# Advanced & Preferred: iFrame Purchase Tracking via postMessage
2
2
3
-
4
3
Tracking conversions and user activity accurately within an iFrame (like the Showpass embedded purchase widget) is a significant challenge due to browser privacy measures that increasingly block third-party cookies and tracking mechanisms.
5
4
6
5
To overcome this, Showpass advocates for a more robust method: **iFrame tracking using the postMessage API**. This technique allows secure communication between the Showpass iFrame (child) and your website (parent page), enabling the iFrame to send event data directly to your GTM container on the parent page.
@@ -25,6 +24,7 @@ For more context on iFrame tracking challenges and solutions:
25
24
This setup involves two Google Tag Manager containers:
26
25
27
26
1.**Child GTM Container (for the Showpass iFrame):**
27
+
28
28
- Create a new **empty GTM Container ID**
29
29
- This container is specifically for the Showpass widget environment
30
30
- Its role is to capture ecommerce events within the iFrame and `postMessage` them to the parent window (your website)
@@ -77,17 +77,17 @@ This tag will send data from the iFrame's Data Layer to your parent website.
77
77
</script>
78
78
```
79
79
80
-
-**Crucial:**
81
-
- Ensure you have enabled the **Support document.write** checkbox (under Advanced Settings) if required
82
-
-**Replace `GTM_CHILD_ID`** in the script with your actual Child GTM Container ID (e.g., `GTM-XXXXXXX`)
83
-
- The script above assumes your child GTM Data Layer is named `dataLayer_GTM-XXXXXXX` (where `GTM-XXXXXXX` is your Child Container ID). GTM creates this namespace automatically to avoid conflicts
80
+
-**Crucial:**
81
+
- Ensure you have enabled the **Support document.write** checkbox (under Advanced Settings) if required
82
+
-**Replace `GTM_CHILD_ID`** in the script with your actual Child GTM Container ID (e.g., `GTM-XXXXXXX`)
83
+
- The script above assumes your child GTM Data Layer is named `dataLayer_GTM-XXXXXXX` (where `GTM-XXXXXXX` is your Child Container ID). GTM creates this namespace automatically to avoid conflicts
84
84
85
85
4.**Triggering:**
86
86
- Click **Choose a trigger to make this tag fire...**
87
87
- Select a trigger like **Custom Event**
88
88
-**Event name:** Use regex matching to fire on all Showpass ecommerce events:
> **Security Note:** In production, you should verify `event.origin` to ensure messages are only accepted from trusted sources (e.g., `https://showpass.com` or your own domain).
182
+
> **Security Note:** In production, you should verify `event.origin` to ensure messages are only accepted from trusted sources (e.g., `https://showpass.com` or your own domain).
170
183
171
184
4.**Triggering:**
172
185
- Click **Choose a trigger to make this tag fire...**
Copy file name to clipboardExpand all lines: src/docs-app/data/google-tag-manager/09-advanced-tracking-widget-and-direct-purchases.md
+15-73Lines changed: 15 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
# Advanced: Differentiating Widget (iFrame) vs. Direct Showpass.com Event Tracking
2
2
3
-
4
3
In some advanced scenarios, you might want to differentiate GTM tag firing behavior based on whether an event originates from within the embedded Showpass widget (iFrame on your site) or from a direct interaction on `showpass.com` (if your GTM container is also deployed there, or if Showpass sends server-side events that populate your website's GTM).
5
4
6
5
This allows for more granular control, such as:
@@ -47,90 +46,33 @@ function() {
47
46
48
47
Now, use the `{{Custom JS - Is iFrame}}` variable as a condition in your relevant GTM triggers.
49
48
50
-
### Scenario A: Triggers for postMessage Data (from Showpass Widget)
51
-
52
-
These triggers should **only** fire when the event data originates from the iFrame via `postMessage`.
53
-
54
-
-**If your postMessage listener tag** (from Section 8B) pushes distinct events: You might not need to modify the triggers for your actual ecommerce tags (like GA4 ecommerce) if those tags are already listening for the specific events pushed by your listener (e.g., `iframe_add_to_cart`)
55
-
-**If your postMessage listener tag pushes standard event names** (e.g., `add_to_cart`) that could also occur directly on your site or `showpass.com`:
56
-
You need to ensure the triggers for tags that should **only** process iFrame `postMessage` data have an added condition
49
+
Rename your existing Custom ecommerce trigger for processing direct purchases **Showpass - Ecommerce events - direct purchase**
57
50
58
-
1. Edit the relevant trigger (e.g., the one that fires your GA4 ecommerce tag for events received via `postMessage`)
59
-
2. Under "This trigger fires on," add a condition:
60
-
-`{{Custom JS - Is iFrame}}`**equals**`false`
51
+
**Event name**
61
52
62
-
> **Note:** This assumes your listener for postMessage events is on the parent page, and the data is pushed to the parent's dataLayer. The 'Is iFrame' variable on the parent page will be `false`. The logic here depends on where the final decision to fire a tag is made based on the source of the data.
63
-
64
-
### Scenario B: Triggers for Direct Showpass.com Events
0 commit comments