简体   繁体   English

如何捕获“脚本标签”值并将其附加到链接

[英]How to capture a “script tag” value and append it to a link

I have installed an "affiliate management software" in my hosting account. 我已经在托管帐户中安装了“会员管理软件”。

I have created a landing page and I want my affiliates to promote this landing page. 我已经创建了一个登录页面,我希望我的会员推广此登录页面。 Each affiliate will have a unique affiliate link. 每个会员都有一个唯一的会员链接。

Each affiliate link has this format: 每个会员链接具有以下格式:

http://www.mywebsite.com/AM/index.php/uswername

The flow of the process is: Customer clicks an affiliate link(for product 1) ---> Landing Page 流程如下:客户单击关联链接(针对产品1)--->登陆页面

In my landing page, I have included a script tag provided by the "affiliate management software". 在登录页面中,我包含了“会员管理软件”提供的脚本标签。 This script tag dynamically shows the affiliate's username on the page. 该脚本标签在页面上动态显示会员的用户名。 The script tag format is: 脚本标签格式为:

<script src="http://www.mywebsite.com/AM/js/show/username"> </script>

This is the description of the script tag by the "affiliate management software": 这是“附属管理软件”对脚本标签的描述:

The Javascript API allows you to show specific affiliate data on external pages using simple Javascript calls. Javascript API允许您使用简单的Javascript调用在外部页面上显示特定的会员数据。 For example: <script src="http://www.mywebsite.com/affiliates/js/show/username"></script> . 例如: <script src="http://www.mywebsite.com/affiliates/js/show/username"></script> Once a user has clicked on an affiliate link, adding that javascript above to the landing page will show the referring affiilate's username on the page. 一旦用户点击了会员链接,将上面的javascript添加到登录页面将在页面上显示推荐会员的用户名。

My Issue 我的问题

In the landing page I have included another affiliate link (for product 2) and I want to append the affiliate's username to this link so that he get the commission from the sale of product 2. 在登录页面中,我包括了另一个会员链接(针对产品2),并且我想将会员的用户名附加到此链接,以便他从产品2的销售中获得佣金。

I am trying to capture the value of a "script tag" and assign it to a variable. 我正在尝试捕获“脚本标签”的值并将其分配给变量。 and then, print the value stored in the variable at the end of the 2nd affiliate link. 然后在第二个会员链接的末尾打印存储在变量中的值。

So my goal is basically capturing the username and then reprinted it at the end of the 2nd affiliate link. 因此,我的目标基本上是捕获用户名,然后在第二个会员链接的末尾重新打印该用户名。 I want to capture the username printed by the script tag and append it to the 2nd affiliate link in the landing page, so that the 2nd affiliate_link will belong to the affiliate who initially referred the customer. 我想捕获由脚本标记打印的用户名,并将其添加到登录页面中的第二个会员链接,以便第二个affiliate_link属于最初推荐客户的会员。


Here is a simple solution I came out with (but didn't work): 这是我想到的一个简单解决方案(但是没有用):

I created a form in my landing page: 我在目标网页上创建了一个表单:

<form action="go.php" method="get"> 
<script src="yourdomain.com/affiliates/js/show/username/field">; </script> 
</form> 

The reason for creating the form because, according to the "affiliate management software": 创建表格的原因是因为,根据“会员管理软件”:

You can also show affiliate data in a hidden field, so that you can add hidden form fields to any web form that you want. 您还可以在隐藏字段中显示会员数据,以便可以将隐藏表单字段添加到所需的任何Web表单中。 Just append the field value to each javascript call, and it will do a javascript: document.write('<input type="hidden" name="username" value="joe">'); 只需将字段值附加到每个javascript调用中,它将执行一个javascript: document.write('<input type="hidden" name="username" value="joe">');

In go.php, I have the following code: 在go.php中,我有以下代码:

<?php $username = $_GET['username']; 
 header("Location: http://www.mywebsite.com/AM/index.php/$uswername); ?> 

First thing is that you need to concatenate the variable to the url, do this: 首先,您需要将变量连接到url,执行以下操作:

<?php 
    $username = $_GET['username']; 
    header("Location: http://www.mywebsite.com/AM/index.php" . &uswername); 
?> 
<?php 
$username = $_GET['username']; 
$url  = "http://www.mywebsite.com/AM/index.php".$uswername;
 header("Location: ".$url; ?> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM