- OurPcGeek
- Posts
- How to Capture Multiple Query Parameters in the s.campaign Variable of Adobe Analytics
How to Capture Multiple Query Parameters in the s.campaign Variable of Adobe Analytics
Streamline Campaign Tracking: Capturing and Combining Multiple Query Parameters in Adobe Analytics
When working with Adobe Analytics, capturing multiple query parameters and combining them into a single s.campaign
variable can enhance your tracking capabilities. This guide explains how to achieve this using a simple code snippet.
Scenario
You want to capture the values of the following query parameters:
cmpid: Campaign ID
source: Traffic source
medium: Traffic medium
For example, given the URL:www.example.com?cmpid=hhhh&source=ssss&medium=dddd
Code to Use
To concatenate the query parameters into the s.campaign
variable, use this code snippet:
s.campaign = s.Util.getQueryParam('cmpid') + ":" + s.Util.getQueryParam('source') + ":" + s.Util.getQueryParam('medium');
Explanation
s.Util.getQueryParam()
:
This method retrieves the value of a specific query parameter from the URL.Concatenation:
The+ ":" +
syntax combines the values of the query parameters with colons (:
) as separators.Result:
If the URL is:www.example.com?cmpid=hhhh&source=ssss&medium=dddd
Thes.campaign
value will be:hhhh:ssss:dddd
Output Example
After executing the code, the s.campaign
variable will store the following string:
s.campaign = "hhhh:ssss:dddd";
This combined string can now be used for campaign tracking in Adobe Analytics.
Benefits
Compact Tracking: Combine multiple query parameters into one variable to streamline your reporting.
Improved Analytics: Gain deeper insights by tracking source, medium, and campaign ID together.
Ease of Implementation: A single line of code simplifies the process.
By implementing this approach, you ensure a cleaner and more insightful data capture for your campaigns in Adobe Analytics.
Reply