smuralisankar
asked on
Understanding what a javascript code snippet does
Could someone please explain what exactly this javascript code does
What does this code do? Can someone please explain?
This is the website:
freshdesk.com
The process is that users go to the landing page and sign in, then they get here: freshdesk.com/signup/thank -you
That is where the floodlight conversion pixel /tag is placed for tracking signups or conversions.
When someone signups, a unique "thank you" page is generated, here is an example:
http://freshdesk.com/signup/thank-you?redirect=http%3A%2F%2Ftestcompanyname1.freshdesk.com%2Fsignup_complete%2FndPAXFOfs7TEYnbE5WsC&account=testcompanyname1
<script type="text/javascript">
$(document).ready(function(){
var fullstring = getParameterByName("redirect");
var subdomainarray = fullstring.split("/");
var sub_domain_url = subdomainarray[2];
var img_hit = '<iframe src="http://4520586.fls.doubleclick.net/activityi;src=4520586;type=Freet0;cat=FreeT0;qty=1;u1=['+sub_domain_url+'];cost=[Revenue];ord=[OrderID]?" width="1" height="1" frameborder="0" style="display:none"></iframe>';
$("#doubleclick_img_pixel").append(img_hit);
});
</script>
<div id="doubleclick_img_pixel"></div>
What does this code do? Can someone please explain?
This is the website:
freshdesk.com
The process is that users go to the landing page and sign in, then they get here: freshdesk.com/signup/thank
That is where the floodlight conversion pixel /tag is placed for tracking signups or conversions.
When someone signups, a unique "thank you" page is generated, here is an example:
http://freshdesk.com/signup/thank-you?redirect=http%3A%2F%2Ftestcompanyname1.freshdesk.com%2Fsignup_complete%2FndPAXFOfs7TEYnbE5WsC&account=testcompanyname1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
1.
testcompanyname1.freshdesk .com is the unique ID.
When someone signups, they enter "testcompanyname1" for their account sub domain or account name.
freshdesk.com/signup - see that. It is our signup page. You can sign up and see for yourself.
No one can enter a sub-domain if already exists.
So, the url is going to be unique for each account or signup or conversion.
2.
I am not a tech guy so I have trouble understanding this.
Everything you have explained is fine.
So, the subdomain URL is now stored to a variable called u1?
How would that variable be picked up and passed into DFA (our adserver)?
testcompanyname1.freshdesk
When someone signups, they enter "testcompanyname1" for their account sub domain or account name.
freshdesk.com/signup - see that. It is our signup page. You can sign up and see for yourself.
No one can enter a sub-domain if already exists.
So, the url is going to be unique for each account or signup or conversion.
2.
I am not a tech guy so I have trouble understanding this.
Everything you have explained is fine.
So, the subdomain URL is now stored to a variable called u1?
How would that variable be picked up and passed into DFA (our adserver)?
So, the url is going to be unique for each account or signup or conversion.I understand - if the sub-domain is unique then yes the request will be unique and no other code is necessary (in theory - depends on how DA interprets the request)
In answer to the second question - the iframe is how the information is passed. The iframe acts like a browser. When you set the src attribute and then attach the <iframe> to the <div id="doubleclick"> this results in the url that is in the src attribute being loaded into the iframe - in other words the url is executed.
So, the subdomain URL is now stored to a variable called u1?
Yes
ASKER
So, the subdomain URL is now stored to a variable called u1? - yes
1. Where exactly is it stored?
2. I don't understand how that is picked up by the adserver?
1. In the URL
http://4520586.fls.doubleclick.net/activityi;src=4520586;type=Freet0;cat=FreeT0;qty=1;u1=[testcompanyname1.fresh desk.com];cost=[Revenue];ord=[Order ID]?
The subdomain gets inserted into the url string as above - refer the part in bold
2. An iframe is an in page element that acts as a browser. For instance
As you can see there is an instance of EE in the middle of the page - the URL that is the src attribute of the IFrame was called to create this in page element.
In your case the same thing happens except the IFrame is hidden. The SRC attribute of the IFRame calls back to the Adsever server with the parameters shown - they pickup the parameters from the HTTP request - done.
http://4520586.fls.doubleclick.net/activityi;src=4520586;type=Freet0;cat=FreeT0;qty=1;u1=[testcompanyname1.fresh
The subdomain gets inserted into the url string as above - refer the part in bold
2. An iframe is an in page element that acts as a browser. For instance
<iframe src="http://www.experts-exchange.com"></iframe>
This will create an instance of EE in the page. For example <!doctype html>
<html>
<body>
<p>This is before the IFrame</p>
<iframe src="http://www.experts-exchange.com"></iframe>
<p>This is after the IFrame</p>
</body>
</html>
Creates this pageAs you can see there is an instance of EE in the middle of the page - the URL that is the src attribute of the IFrame was called to create this in page element.
In your case the same thing happens except the IFrame is hidden. The SRC attribute of the IFRame calls back to the Adsever server with the parameters shown - they pickup the parameters from the HTTP request - done.
ASKER
How was the screenshot taken? I did you test out the iframe?
I took a screen grab of the browser.
The iframe is exactly the same as if you cut and pasted the URL into your browser - it calls the page on the URL with the parameters given - once that happens the process on the server can retrieve the parameters and do with them whatever needs to be done.
I did you test out the iframe?Not sure what the question is asking.
The iframe is exactly the same as if you cut and pasted the URL into your browser - it calls the page on the URL with the parameters given - once that happens the process on the server can retrieve the parameters and do with them whatever needs to be done.
The example was meant to demonstrate how an <iframe> works - in your case the iframe is hidden because its primary function is to send parameters to your click monitoring service
ASKER
We don't generate an order ID or transaction ID for each signup but we do generate a unique thank you page URL for each signup.
This is the thank you page where we would have the DFA conversion tag:
freshdesk.com/signup/thank
This is the unique thank you page URL that would be generated for each signup (This is just for one account):
http://freshdesk.com/signup/thank-you?redirect=http%3A%2F%2Ftestcompanyname1.freshdesk.com%2Fsignup_complete%2FndPAXFOfs7TEYnbE5WsC&account=testcompanyname1
The javascript code snippet that I posted would work on this URL.
Could you explain how that would happen please?