Smart List: Tracking codes not carried past original page

Posted in: Newspaper
Post count: 28

Hey guys-

I absolutely LOVE the smart list features (especially 6, 7 and 8!).

We have an issue that I’m hoping to get some direction on-

We use tracking codes for different uses on our articles and the smart list articles are not recognizing/maintaining these codes through the different pages of the article.

Example:

If I post an article with a tracking code like this-

website.com/smart-list-article/?tracking-code=abc

When the user clicks NEXT they are taken to

website.com/smart-list-article/2/

Then..

website.com/smart-list-article/3/

Etc…

What we’d like is for the additional pages to keep the tracking code appended, like this:

website.com/smart-list-article/?tracking-code=abc
website.com/smart-list-article/2/?tracking-code=abc
website.com/smart-list-article/3/?tracking-code=abc
website.com/smart-list-article/4/?tracking-code=abc
etc…

Any suggestions on how to accomplish this?

Post count: 1291

Hi,

What plugin do you use to add the tracking code?
A quick solution would be to modify the pagination code, add the tracking code after each link, ex – http://screencast.com/t/gHvR7PkGZ
If the code is dynamic replace the $dynamic_code variable with the one generated by the plugin.

Thank you!

Post count: 28

Hi Emil-

This is wonderful, thanks for the detailed reply.

I’m not using a plugin to generate the the query string. This is for tracking affiliate codes, Google analytics UTM codes, and similar items that are added at the time the article is shared via social media, email, etc.

I’d like to configure the site to pass “any” query string to all of the pages within the smart lists. In other words, if a visitor hits a smart list with http://site.com/smart-list/?var1=abc&var2=def&var3=ghi , I’d like that whole string to be appended to each additional page of the smartlist.

I think using $_SERVER[‘QUERY_STRING’] would do the trick but I’m not confident in my PHP skills and don’t have a test site to play with.

Can you assist?

Thanks!

Post count: 1291

Hi,

You could try this hook – https://codex.wordpress.org/Plugin_API/Filter_Reference/post_link
Ex – http://screencast.com/t/cxKwRCfTf

But on custom links it will not work, ex – http://screencast.com/t/3B07YWB66

An alternative would be to look for a javascript solution.

Thank you!

Post count: 28

I played around with the PHP but settled on a JS solution.

If anyone else needs to make this work here is what we used:

jQuery('a.td-smart-list-button').each(function () {
var href = jQuery(this).attr('href');
if (href !== undefined) {
var urlparam = location.search;
href = href + urlparam;
jQuery(this).attr('href', href);
}
});

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newspaper’ is closed to new topics and replies.