Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Randomized Referral!

K-MTG

Sunshade Captain of TMC
Oct 24, 2015
4,815
3,508
Irvine, CA

I created a simple webpage where Tesla owners can input their referral link. The inputted referral link automatically randomizes each time the page is loaded so prospected buyers have a link to choose from.

Tesla Owners: Feel free to add your referral link to the randomizes list.

Prospected Buyers: It must be hard to choose a referral link as they are so many helpful members on TMC, you may use this site to obtain a randomized referral link.


I appreciate any feedback
 

K-MTG

Sunshade Captain of TMC
Oct 24, 2015
4,815
3,508
Irvine, CA
Sorry about the typo ... I corrected the original question. I'm Just looking for the number of referrals that are requested by buyers

Good idea, I will search for a solution that lets me do that.

Anyone familiar with HTML/PHP?
As you can see, I created a PHP script that picks a random line from a .txt file on the server. So whenever anyone loads the page they will get a random referral URL that is posted on the .txt file.
I also have a input forum embedded on the page from Wufoo that emails me the link whenever anyone submits their referral URL. So I have to manually copy and paste the referral URL onto the .txt file on my server. Anyone know of a faster solution, that will automatically post the URL from the forum to the .txt file?

Thanks
 

K-MTG

Sunshade Captain of TMC
Oct 24, 2015
4,815
3,508
Irvine, CA
I'd write back to the .txt file using a delimiter to tag on the number of referrals. That way you only need to be familiar with file IO and you get to learn about string manipulation.

Be sure to test thoroughly before deployment!

You lost me :confused:... I will take a look at it and do some research.
But I am debating if I should make it automatic (based on your instructions) or leave it alone since I currently get to moderate the links people submit to make sure nobody spams the input forum with links forwarding to other sites.
However if you have time, I can PM the php file to you it is a very simple site with only one page.
 

Jason S

Model S Sig Perf (P85)
Apr 20, 2012
1,590
213
Rocklin, CA
I haven't coded PHP in years! And even then I was just hacking somebody else's code.

Here's the overview of what I'm suggesting:

You have a .txt file filled with URLs like so (I put a space after the first w so the forum wouldn't auto url these):
w ww.myplace.net
w ww.myotherplace.net
w ww.myplace.net/foo/bar

And you want to track how many referrals each gets. Right now you are choosing a random line in the file. So just write back to the file with the number after a special character (or two or w/e). Like so:

w ww.myplace.net|1
w ww.myotherplace.net|3
w ww.myplace.net/foo/bar|2

So your code would operate like this:
1) choose a random line
2a) if delimiter in the line, spit out everything before the delimiter (|), increment the number after the delimiter
2b) (else) since no delimiter just spit out the line and attach |1 at the end of the line.
3) write back the file

Really quick, really simple. And you just keep adding lines to the file manually whenever you want. Just remember to shut down the web page whenever you update the file with your additions (stop page, add lines via copy/paste, start page).
 
Last edited:

K-MTG

Sunshade Captain of TMC
Oct 24, 2015
4,815
3,508
Irvine, CA
I haven't coded PHP in years! And even then I was just hacking somebody else's code.

Here's the overview of what I'm suggesting:

You have a .txt file filled with URLs like so (I put a space after the first w so the forum wouldn't auto url these):
w ww.myplace.net
w ww.myotherplace.net
w ww.myplace.net/foo/bar

Yup, that is what I have.

And you want to track how many referrals each gets. Right now you are choosing a random line in the file. So just write back to the file with the number after a special character (or two or w/e). Like so:

w ww.myplace.net|1
w ww.myotherplace.net|3
w ww.myplace.net/foo/bar|2

So your code would operate like this:
1) choose a random line
2a) if delimiter in the line, spit out everything before the delimiter (|), increment the number after the delimiter
2b) (else) since no delimiter just spit out the line and attach |1 at the end of the line.
3) write back the file

Really quick, really simple. And you just keep adding lines to the file manually whenever you want.

I should have mentioned this before, this is my first time coding in PHP. Let me show you what I have now (I took out the stuff that doesn't matter):
Code:
<?php
$text = file_get_contents('Data.txt');
$textArray = explode("\n", $text);
$randArrayIndexNum = array_rand($textArray);
$randPhrase = $textArray[$randArrayIndexNum];
?>
<html>
<body>


<center>
<h1>
<a href="<?php echo $randPhrase; ?>">YOUR RANDOM  REFERRAL LINK</a>
</center>
</h1>


</body>
</html>

If I add values after the domain of the referral link won't it prevent the page from hyperlinking properly?
 

HankLloydRight

No Roads
Supporting Member
Jan 18, 2014
13,616
12,073
Connecticut
Great idea for the randomizer, but I don't think tracking the number of referrals is possible. What you're tracking is either the number of times any particular referral link is displayed (increments one with each new page load), or with a little more code, the number of times a referral link is clicked. Neither of those will really reflect the actual number of referrals.

I would like to see the total number of referral links currently being chosen from, though.

- - - Updated - - -


Also, I know it's a manual process now, but I'd add code to make sure that any submitted referral link is a real Tesla referral link, and not a link to someone's Tesla Referral webpage or custom domain.

- - - Updated - - -

If I add values after the domain of the referral link won't it prevent the page from hyperlinking properly?

You would need to break out the counters, like this:

PHP:
$randPhrase = explode('|',$textArray[$randArrayIndexNum]);
$url=$randPhrase[0];
$counter=$randPhrase[1];
Code:
<a href="<?php echo $url; ?>">YOUR RANDOM  REFERRAL LINK</a> Counter: <? echo $counter; ?>
 

Reeler

Decade of Pure EV Driving
Oct 14, 2015
1,765
1,318
Denver, CO
If someone's link gets used three times there needs to be a way to get it removed from the list because after three it is no longer a valid link.
Unfortunately having it copied three times does not mean it has actually been used three times. Only the link owner will have that information.

That is a great idea. Maybe allow the folks providing their link the ability to opt out once they receive 3 to let others have a chance.

- - - Updated - - -

Has anyone received a referral yet in the new program? Will there be a counter like before at MyTesla?
 

HankLloydRight

No Roads
Supporting Member
Jan 18, 2014
13,616
12,073
Connecticut
Has anyone received a referral yet in the new program? Will there be a counter like before at MyTesla?

Yes, I've received one credit so far (and I believe one more pending confirmation), and the MyTesla page updates with the counter. I don't know what happens after 3 referrals, if it will indicate that there are no more available.

What happens to a buyer who uses someone's referral link who is maxed out? I suspect they still get the $1200 credit, but the referrer gets maxed out at 3. It would suck of the buyer gets a message "referrer link bad, please try another".
 

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top