Integrate with other analytics platforms to report the serving of experiences and variations. This lets you view reports of users/sessions that were exposed to an experience or a variation in other platforms, or “tag” these users as users that were exposed to a specific experience.
Note: This feature in only available for web and mobile sites. It isn't available for native mobile apps, or API campaigns.
Setting up a custom analytics platform integration
- Go to Settings › Integrations.
- Enable the Custom Analytics Platform integration
-
Select the trigger that will determine when the custom integration code is run.
- Variation Impression: Run the code when a variation of an experience is selected for a user.
- Variation Serve: Run the code when when a variation is served to a user.
- Recommendation Impression: Run the code when a recommendation is served to a user.
-
Write a custom JavaScript that complies with the relevant platform’s API.
-
The JavaScript can include metadata such as the variation name, the experience or campaign names, the strategy (for recommendations), and more.
-
Click Show Example to see an example integration with comments.
-
Assumed cookie consent only: If you are using any of our Visitor Data Privacy Management APIs, you need to use a dedicated API to ensure that no data is sent to a third party for users who do not consent.
-
The new syntax included in Javascript ES6 is not supported.
-
- By default, the custom analytics platform integration will be served when any campaign matches is triggered. You can manually enable or disable the integration for individual campaigns using the procedure below.
Enabling and disabling a custom integration per campaign
By default, the custom analytics platform integration will be enabled for all campaigns. The integration can be turned off per campaign. This is done in the Advanced Settings of the campaign.
- When editing or creating a campaign, go to Advanced Settings.
- Turn off (or on) Enable custom integration.
Troubleshooting custom analytics integrations
If you've set up your custom analytics integration, but are not seeing Dynamic Yield campaign data in your analytics platform, try these methods to troubleshoot the integration code and confirm that it is working as expected.
If after trying these actions events are still not triggered for Dynamic Yield campaigns, contact technical support.
Console.log
Using console.log() is a classic method in debugging code. It writes strings of text to the console of your browser’s dev tools (press ⌘+⌥+J for MacOS or Ctrl+Shift+J for Windows). In the following example, console.log() is used to check whether our code executes successfully and that values are being assigned to our variables.
To take this a step further, you can use console.log() to make sure the Dynamic Yield campaign data is being assigned to the variables passed in the afterVariationSelected function.
Breakpoints
Breakpoints can be used to stop the execution of code in the browser, which enables you to step through the code line by line to review it.
To add breakpoints to the code contained in your custom analytics integration:
- Open dev tools in your browser (press ⌘+⌥+J for MacOS or Ctrl+Shift+J for Windows).
- Click the three dots on the menu bar, and then click Open File.
- Search for “api_dynamic” and open the JS file by clicking on it.
- Click Pretty-Print.
- Search for the name of the function from your custom analytics integration code. In this example we searched for “afterVariationSelected”. However, this might be different depending on the type of custom integration you’re using. Refer back to your integration in Dynamic Yield if you’re not sure what to use in your search.
- Click line numbers to add breakpoints where want to stop the code from executing. In this example, we added a breakpoint to stop the code before it executes the gtag event.
- Refresh the page you are troubleshooting. In the dev tools console, you can see the page stop loading, and your breakpoint is displayed.
You can now see what values are assigned to the minified variables that are passed in the afterVariationSelected function. If you resume the execution of the code, you might see that it iterates through and stops at the same breakpoint multiple times if you are firing the custom analytics integration code for multiple campaigns on the page.
Note that you will not see the code iterate through campaigns that do not have the custom analytics integration toggle enabled in the campaign settings. - Experiment by adding additional breakpoints in the code, or use Step
to step through the code after the breakpoint is reached.
Use the correct event measurement code for Google Analytics
If you’re still not seeing Dynamic Yield campaign events in Google Analytics, you might be using the wrong syntax in your event measurement code. Depending on your implementation, you must use either the ga() or gtag() syntax.
To verify the correct code syntax for your site, refer to the event measurement documentation in this Google Analytics article.