Home > Technical & Creative Skills > Programming, Servers & Scripts

Passing GET parameters using javascript (8)


05-09-2017 09:21 PM #1 jelz03 (Member)
Passing GET parameters using javascript

Hey everyone, feels like I'm spending so much time in this part of STM... Anyways, here's what I'm working on right now: passing GET parameters using javascript.

Here's my setup:

Traffic source => www.myurl.com/redirect.php => www.MyTracker.voluumtrk.com => Landing Page => Offer

At the traffic source, my link is www.myurl.com/redirect.php?zoneid=[zoneid] and I want the zone ID to be passed to my tracker so I can cut bad placements.

What I've come up with:

Code:
<script>
function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] || ''
    );
}


    function goto(){
        var url = "http://xxxx.voluumtrk.com/click?zoneid=" + encodeURIComponent(getURLParameter("zoneid"));
            window.location.href = url;
    }
</script>
In my tests it looks like it's passing the value correctly but it doesn't appear in my tracker.

How can I solve that?


05-09-2017 09:33 PM #2 matuloo (Legendary Moderator)

Why don't you use the campaign urls generated by Voluum directly - is there a reason why you want to use the myurl.com/redirect.php at the source instead of the Voluum campaing link?

You can define custom variables in voluum and have them all be a part of the campaign url.


05-09-2017 09:42 PM #3 jelz03 (Member)

The reason why I'm not using the Voluum campaign link is that it's filtering bots and competitors trying to spy on my funnel.

The variables are set in Voluum in the traffic source settings page, like so:
Click image for larger version. 

Name:	TS.PNG 
Views:	27 
Size:	46.5 KB 
ID:	15289

But it still doesn't pass


05-09-2017 09:56 PM #4 voluum (Veteran Member)

Hi jelz03,

The script that you have seems to be okay (assuming that later on you're calling the goto() function that you have defined), but the URL that you're constructing is a Click URL - it's the one that you use to redirect from the landing page to the offer.

In the scenario that you have described, you need to pass it to the Campaign URL (the one that redirects to the landing page, looks for example like this: http://xxxxx.voluumtrk.com/b5e8e3bb-...63c745?zoneid=[zoneid] ) - only then we will be able to track that information.

It is possible to append parameters to a Click URL - but it's mostly used when there's an input on the landing page itself, for example when user has to input his email address, and you want to pass it to the affiliate network as a parameter, then you can add it to the click URL by appending /click?email=sample@email.com, and then &email=sample@email.com will be appended to the offer URL.

Kind regards,
Pawel


05-10-2017 09:49 AM #5 jelz03 (Member)

Hi Pawel,

Indeed it makes a lot of sense to pass the parameter to the tracking url instead of the click url, thanks for pointing it out.

However when I try to pass the parameter to the tracking url I have a double value like

Code:
http://xxxxx.voluumtrk.com/b5e8e3bb-...63c745?zoneid=[zoneid]&zoneid=12345
and it doesn't get tracked in Voluum, I still get [zoneid] instead of 12345.

How come another value is added instead of simply replacing [zoneid] ?


05-10-2017 11:26 AM #6 newyorkheart2000 (Member)

nice post.


05-10-2017 01:15 PM #7 voluum (Veteran Member)

Hi,

Quote Originally Posted by jelz03 View Post
How come another value is added instead of simply replacing [zoneid] ?
That function you have defined - getURLParameter - only returns value of a parameter in the URL - it won't automatically replace a placeholder.

getURLParameter("zoneid") will return value of zoneid parameter only, so if you have &zoneid=123456 in the URL, getURLParameter("zoneid") will return "123456". You need to pass that value to the Campaign URL under the right parameter, so in place of [zoneid] placeholder:

Code:
var url = "http://xxxxx.voluumtrk.com/b5e8e3bb-9eec-4c18-a458-e9243463c745?zoneid=" + encodeURIComponent(getURLParameter("zoneid"));
Kind regards,
Pawel


05-11-2017 09:51 AM #8 jelz03 (Member)

Thanks Pawel, some stupid mistakes I made prevented from making it work.

It's working now, thanks!


Home > Technical & Creative Skills > Programming, Servers & Scripts