BrainPill Posted April 28, 2018 Share Posted April 28, 2018 Hello I'm facing a problem I cant really solve. I want to place a backlink in the shape of either a textlink or an img banner outside my own server. (for instance inside an iframe) I want to be able to track download impressions and referrer clicks. Can this be done with php or not? It seems technically not possible to place php on someone else's server. What would you recommend? Link to comment Share on other sites More sharing options...
Ingolme Posted April 28, 2018 Share Posted April 28, 2018 For any external link, on your own server you can use the referrer header $_SERVER['HTTP_REFERER'] to know the URL of the page that the user was on when the user clicked the link. Some browsers may be configured to not send this for privacy reasons. It is not normal to ask somebody to put PHP code on their server, but you can tell them what HTML to use for the link. If you can make deals with the person who is linking back to you, a common technique is to add a query string to the link which provides information. You would give a different query string for each website that links back to you. Link to comment Share on other sites More sharing options...
BrainPill Posted April 29, 2018 Author Share Posted April 29, 2018 okay but in what way can I count the number of downloads of an html element? Can that be done with HTML/PHP or is another language needed? Link to comment Share on other sites More sharing options...
BrainPill Posted April 30, 2018 Author Share Posted April 30, 2018 On 4/28/2018 at 9:32 PM, Ingolme said: For any external link, on your own server you can use the referrer header $_SERVER['HTTP_REFERER'] to know the URL of the page that the user was on when the user clicked the link. This only works when a user clicks the link. But that is not what I want. I want to know the download, so I assume javascript is moreoften used. I am not really familiar with javascript. What is the easiest and least restricted / blocked way of doing it in AJAX/Javascript/jquery? Link to comment Share on other sites More sharing options...
dsonesuk Posted April 30, 2018 Share Posted April 30, 2018 You need to store in database or write to xml, so the better option would be to use PHP. This is probably more than you want, but it shows you how to setup to update file count in database etc https://tutorialzine.com/2010/02/php-mysql-download-counter You wouldn't necessarily, need to dynamically create links, just make sure the querystring is correct so PHP can get the filename to update the database table filename count. Link to comment Share on other sites More sharing options...
BrainPill Posted May 1, 2018 Author Share Posted May 1, 2018 my idea is that the example you give is not what I want. In the OP I explained I wanted to make a piece of script that registers the number of impressions the text / banner link has. So at the moment a div (or iframe not sure what is the best way) loads on an external site. (not my site, but the site that links to me) I want some code that counts the download and send this information towards a page on my server where I use PHP/mysql to store the number in my database.table. The visitor should not have to click (yet) so before the click the div has loaded and that's what I would like to measure. The more I try to grasp this set up , the more I become convinced it can not be done with PHP but rather with javascript. Maybe it is possible, but I would like an easy set up. So everyone who wants to link towards my site should be able to easily copypaste some code and paste it in. This makes me think javascript is the best solultion. Not 100% sure so that's why I wanted to ask it here. So if these impressions cant be measured with php then let me know and I go on in javascript. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 1, 2018 Share Posted May 1, 2018 You're measuring things they are clicking inside the iframe, right? If you're trying to measure things they click on the parent site from inside the iframe, you're not going to be able to do that because Javascript running inside the iframe can't interfere with the parent site if it's on another domain. If you're just trying to measure how many times the iframe gets shown, that's as easy as updating a database table every time your page gets loaded. So everyone who wants to link towards my site should be able to easily copypaste some code and paste it in. That kind of terminology is part of why people are confused. You're not talking about linking to your site, you're talking about embedding an iframe. Those are completely different things. Linking to your site means putting an anchor tag on the page pointing to your site. That's not what you're talking about here. And if you're talking about "impressions", using the same terminology that advertisers use, then you're just counting page views for the page that's inside the iframe. That's what I described above. 1 Link to comment Share on other sites More sharing options...
BrainPill Posted May 2, 2018 Author Share Posted May 2, 2018 (edited) Great answer . I got it working they way you said it. Using the right definitions surely does clarify a lot. But one thing I could not get to work was the way of passing the $_GET query params with the iframe src. But that is a bit of topic maybe. Thanks anyway. Edit: I solved the query string passing with adding a piece of javascript code to the page that was called in the iframe. Edited May 2, 2018 by BrainPill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now