We have an issue where we're not being allowed to use query string params for internal campaigns because of caching issues. Does anyone have any experience with using DTM (specifically data layer) to populate campaign IDs and assign to proper campaign types?
Your next best method would be to add click tracking to the links.
Here is what you can do, to demonstrate the concept.
Let's say you have the following link on your homepage hero banner:
<a href='https://forums.adobe.com/somepage.html'>click me!</a>
Update the link to have something like this:
<a href='https://forums.adobe.com/somepage.html' class='internalCampaign' data-campaign-code='foobar'>click me!</a>
So the first thing is to have something to target the link by. In this example, I added a class called "internalCampaign". In practice, this can be anything you can use a CSS selector to feasibly target. For example, your links may already be wired up with a specific class for those types of links, or within a div with a specific class, etc..
The second thing is to add a data attribute to specify the campaign code for the link. In this example, I use data-campaign-code as the attribute and 'foobar' as the campaign code.
Then within in DTM, create a new event based rule called "Internal Campaign Clicks".
Under Conditions, choose Mouse >Click as the Event Type. Then for the Element Tag or Selector, add the CSS selector path. In this example, it would be "a.internalCampaign" (no quotes).
Next, in the Rule Conditions > Criteria dropdown, select Data > Custom, and then click Add Criteria.
You should now have a Custom code box to add code to. Add the following:
_satellite.setVar('campaignCode',this.dataset.campaignCode); return true;
That piece of code will set a DTM Data Element named campaignCode to the link's data-campaign-code attribute value (in this example, "foobar").
Now, within the Adobe Analytics section (or any other section of the event rule, you will have %campaignCode% available to use as a value in the fields, or within custom code sections, you can use _satellite.getVar('campaignCode').
This was a basic, canned example to demonstrate the concept. There will likely be some tweaks you will need to make, depending on how your site is setup. For example, you may or may not have to apply the event handler directly to the element (checkbox within conditions), alter the Bubbling config, etc.. also, this code example uses html5 data attributes, which may or may not work for you, depending on what kind of browser/browser version compatibility you want your code to have. There are alternative code syntaxes that are old-browser-friendly, but the concept is the same.
As an alternative, you could not pop Adobe Analytics for the event, and instead set a cookie. Then setup a page load rule (or add to an existing one you may have) to look for the cookie and pop your variables from there. The advantage of this is that it will (in theory) take less time to just set a cookie, so less chance that the DTM code and Adobe Analytics code will get cut short before redirect. Also, going the cookie-reading route would mean not having to make an additional request to Adobe Analytics (which costs money!).
Could you explain a little more what you mean by "not being allowed to use query string params for internal campaigns because of caching issues"? I'm not quite sure what the exact problem is.
I may be able to say "yes" to your subsequent question depending on how you answer my question. 🙂