duanlie7962 2014-10-27 22:48
浏览 22
已采纳

如何添加Google Analytics事件跟踪代码以下载php中的链接?

I Added below Google Analytics Event Tracking Code to download link

onClick="ga('send', 'event', 'Redirected2dl', 'QPRedirect');"

i Added the code directly to the php file as shown below . But when i tried to load the webpage the web page does not display!

<?php
$url = $_GET['url'];
echo 
'<p style="text-align: center;"> Your QuestionPaper Will Be Diplayed Here.
<a id="downloadLink" href="http://www.questionspaper.in/wait.php?url='.urldecode($url).'" onClick="ga('send', 'event', 'Redirected2dl', 'QPRedirect');"  >click     here to Download Your QuestionPaper</a>
if (isset ($url)) 
{
echo 
'<iframe ... src="http://docs.google.com/gview?url='.urldecode($url).'&embedded=true"     height="800" width="900" ></iframe>';
 }
 else {
 echo '<iframe ... src="
$url" height="1000" width="1000"></iframe>';
 }
?>

Can Anyone Help me to rectify the problem.Thank you

The above Php File can Be veiwed here http://questionspaper.in/myiframe.php?url=

  • 写回答

1条回答 默认 最新

  • doushan7997 2014-10-27 22:53
    关注

    You need to escape the single quotes in the string you are echoing. You also want to urlencode the url parameter, not decode it.

    <?php
        $url = $_GET['url'];
        echo '<p style="text-align: center;">Your Question Paper Will Be Diplayed Here. 
        <a id="downloadLink" href="http://www.questionspaper.in/wait.php?url='.urlencode($url).'" onClick="ga(\'send\', \'event\', \'Redirected2dl\', \'QPRedirect\');"  >click here to Download Your QuestionPaper</a>';
        if (isset ($url)) 
        {
            echo '<iframe ... src="http://docs.google.com/gview?url='.urldecode($url).'&embedded=true"     height="800" width="900" ></iframe>';
        } else {
            echo '<iframe ... src=" $url" height="1000" width="1000"></iframe>';
        }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机