How can I Pass Tracking IDs of my Source Traffic to Inner Links

Hi I need help with tracking ID My website receives traffic with tracking ID eg example[.]com/?tid=ag1 ; example[.]com?tid=ag2 etc

I have a buy now button there with an external link let’s say “gotothissite[.]com”

I want this external link to automatically modify itself to the tracking ID. So if I get a visit to my website via url example[.]com?tid=google then my external link should automatically modify as gotothissite[.]com/?tid=google

From What I know is that php $_GET[“tid”] can be used to achieve this. Can anyone guide me with it.

P.S. I don’t have any php coding knowledge but I do know HTML and CSS. The website is built on wordpress. [.] is used because of link post limit in the forum and http is removed for the same reason.

<a href='gotothissite.com<?= isset( $_GET['tid'] ) ? "tid=".$_GET['tid'] : "" ?>'>

How can I capture tid value?

“capture” like what, a screenshot?

I mean, How can I capture tid value when someone visits my site and then place it on the code provided above. Here is an example of website: https://pregnancymiracle.infomay.com/?tid=chorn which whenever visited by a tid then the external link’s tid get the same tid?

Please look the tid of buy now button.

PHP does that for you. It’s stored in $_GET['tid'].

Where do I write $_GET['tid'] code. In functions.php file?

Depends entirely on what you’re doing with it. If you’re appending it to links, you’d just… put it on the end of the link. As i wrote in post #2.

I think, with respect, what you need to do is put aside what you actually need to do here, and get yourself a basic familiarity with PHP. You don’t say above whether you’ve any actual programming background, so that will alter whether you’re learning programming and PHP, or just translating knowledge of a language you are familiar with into PHP. I’m also not putting down HTML and CSS or suggesting they’re somehow much “easier”, but they’re quite different to coding.

Sit down and work through some examples on how to do basic stuff with PHP and you’ll see that what you need to do is relatively simple.

I’ve written this code http://prntscr.com/od8i5r yet it doesn’t work output is http://prntscr.com/od8isn

I would love to learn PHP when the time is correct. But I have to get this job done for now.

I missed a ? in that sentence.

<a href='gotothissite.com?<?= isset( $_GET['tid'] ) ? "tid=".$_GET['tid'] : "" ?>'>

And your link doesnt have the link text or closing tag in it.

Might need to learn HTML before trying to learn PHP.

I didn’t used any of my own HTML expirence because I didn’t want to tangle with the codes you wrote.

I have however now used my own skills in it but don’t see the TID. http://prntscr.com/od93t6 http://prntscr.com/od94if

Might you just send me the code which I just copy and paste and see if it works without having to edit even a single char. Just so I know if it works, if it does then I would figure out myself which things to replace when I write it on my website.

Why have you added like 20 quotation marks to the line i gave you? Leave it as is.

ffs…

<a href='gotothissite.com?<?= isset( $_GET['tid'] ) ? "tid=".$_GET['tid'] : "" ?>'>I Cant Write HTML</a>

Still doesn’t work :frowning:

http://prntscr.com/od98pq http://prntscr.com/od98xi

I appreciate the time and energy you have put :slight_smile:

On that, it’d be great if you could post your code in the forum rather than linking to screen shot images, it makes it more difficult to help. Not so much in the short examples we’re doing here, of course. As @m_hutley posts code in the forum, why can’t you copy/paste that into your code?

But generally, the idea of a support forum is to send you in the right direction, rather than just write the code for you.

That still isn’t right, there are far too many quotes and you’ve got a html-encoded part too. Compare it to the post on here.

1 Like

Wait, your code is stored in a file that has a .php extension isn’t it? And opened via a server, not by browsing the file system?

Rightly said! The website is on WordPress CMS

I know nothing about Wordpress, so don’t know whether that answered the questions - I presume that makes it a ‘yes’ to both of them. Just seemed a bit strange that looking in your latest screen shot of the output, it doesn’t seem to have processed the PHP code at all.

Try it this way instead, in case your server doesn’t support PHP short-tags (not sure if that’s possible, but might be worth a try):

<a href='gotothissite.com?<?php echo isset( $_GET['tid'] ) ?
 "tid=".$_GET['tid'] : ""; ?>'>I Cant Write HTML</a>

It doesn’t work. Leave it I just spoke to my web developer. He will come and fix this in a week. I thank all of you for your help.