Skip to content

Commit b7e5572

Browse files
committed
Adding callback integration
1 parent c4852bc commit b7e5572

File tree

3 files changed

+898
-0
lines changed

3 files changed

+898
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Google Analytics Callback Integration
2+
3+
This integration is used to track your Optimizely campaigns and experiments in Google Analytics using a callback method.
4+
5+
## Description
6+
7+
Optimizely's [out of the box integration](https://help.optimizely.com/Integrate_Other_Platforms/Integrate_Optimizely_X_with_Google_Universal_Analytics) utilizes a polling method with a ten second timeout to integrate the two platforms. Mobile clients on slower connections have a higher propensity to trigger this ten second timeout so integration success can skew toward higher performance desktop devices. This integration approach will help remediate instances where the polling integration method times out.
8+
9+
## Prerequisites
10+
11+
1. The config.json file in this folder must be added to your Optimizely account. From the Optimizely Dashboard click Settings > Integrations, then click "Create Analytics Integration" > "Using JSON". After pasting the JSON into the code box the extension will auto-generate.
12+
13+
2. The extension also needs to be enabled from the Integrations tab under the Settings menu.
14+
15+
3. Your experiment of choice needs to have the integration turned on and a custom dimension must be set.
16+
17+
## Implementation
18+
19+
Add this JavaScript code to your page source *after* the `ga` object has been initialized:
20+
21+
```
22+
if (window.optimizely && typeof window.optimizely.get === 'function' && window.optimizely.get("custom/gaIntegrator")) {
23+
window.optimizely.get("custom/gaIntegrator").gaDispatch(window.ga);
24+
}
25+
```
26+
27+
The timing of this code is very important. The `ga` object must be defined so the integration can utilize the Google Analytics `send` command. Note that the `ga` object is being passed as a parameter to `.gaDispatch()`. It's possible your organization uses a [custom `ga` variable](https://developers.google.com/analytics/devguides/collection/analyticsjs/renaming-the-ga-object) so be sure to pass in the appropriate object.
28+
29+
## Tracking Delayed Campaigns
30+
31+
Campaigns using delayed activation methods will be tracked *automatically* with this integration. NOTE: If you are renaming the `ga` object, then you should change lines 34 and 35 of the `integration.js` file to reflect the renamed `window` level object.
32+
33+
## Support
34+
35+
If you have questions about this integration or if you're experiencing unexpected behavior, please submit a support ticket via the Help menu on the left side of the Optimizely Dashboard.

0 commit comments

Comments
 (0)