0

Magentoのインストールから印刷された素晴らしいJavaScriptがあります。ドメインのリストを作成できます。ドメインにリマーケティングリストがある場合は、詳細を入力して、JSがそのドメインにいることを検出したときにリマーケティングを開始できます。

コードは次のとおりです。

$protocol = Mage::app()->getStore()->isCurrentlySecure() ? 'https' : 'http';
    if (!Mage::getStoreConfigFlag('google/analytics/active')) {
        return '';
    }
    $this->addText('<script src="'.$protocol.'://www.googleadservices.com/pagead/conversion.js" type="text/javascript"></script>');
    $this->addText("
<script type=\"text/javascript\">
    // This section finds all links that are outside of the current domain and adds a Google Analytics Cross-Domain Tracking Script
    // THIS IS ABSOLUTELY MAGICAL, SOMETIMES I LAUGH AT HOW CLEVER THIS LITTLE SNIPPET IS
    // I need to get out more
    var domains = {
        'whitestores.co.uk':false,
        'bbqsdirect.co.uk':false,
        'resinweavegardenfurniture-direct.co.uk':{
            'google_conversion_id':1069311156,
            'google_conversion_label':'BDWlCMy72AIQtMnx_QM'
        },
        'metalgardenfurnituredirect.co.uk':false,
        'teakgardenfurniture-direct.co.uk':false,
        'bistrosets-direct.co.uk':false,
        'firepits-direct.co.uk':false,
        'cushions-direct.co.uk':false,
        'benches-direct.co.uk':false,
        'parasols-direct.co.uk':false,
        'covers-direct.co.uk':false,
        'gardenbeanbags-direct.co.uk':false,
        'chimineas-direct.co.uk':false,
        'outdoorfurniture-direct.co.uk':false,
        'stores-direct.co.uk':false
    };

    // Get the current domain name
    var current_domain = document.domain.replace('www.','');

    // Go through each of the domain lists above, check that we aren't going to be affecting links
    // to the domain that we are currently on as this would be unnecessary.
    \$H(domains).each(function(pair){
        var val = pair.key;
        var options = pair.value;

        if(val == current_domain && options){
            console.log('This domain has remarketers');

            <!-- Google Code for Resin Weave Visitors Remarketing List -->

            var google_conversion_id = options['google_conversion_id'];
            var google_conversion_language = \"en\";
            var google_conversion_format = \"3\";
            var google_conversion_color = \"ffffff\";
            var google_conversion_label = \"options['google_conversion_label']\";
            var google_conversion_value = 0;

        }
        if(val != current_domain){

            // Check to see if there are 'a' elements in the code with any of the domains above in the HREF
            // If there is, go through each of them and add an on-click event utilising Google's link tracking feature
            if($(\"a[href*='\"+val+\"']\")){
                $(\"a[href*='\"+val+\"']\").each(function(elemindex,elem){
                    $(elem).click(function(){
                        _gaq.push(['_link',this.href]);
                        return false;
                    });
                });
            }

            // Do the same for forms
            if($(\"form[action*='\"+val+\"']\")){
                $(\"form[action*='\"+val+\"']\").each(function(elemindex,elem){
                    $(elem).attr('onSubmit',\"_gaq.push(['_linkByPost',this])\");
                });
            }

        }
    });

</script>
<script type=\"text/javascript\">
//<![CDATA[
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount','UA-9852071-15']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_trackPageview']);
    ".$this->getQuoteOrdersHtml()."
    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
//]]>
 </script>
 ");

ご覧のとおり、このコードは関連するGoogleクロスドメイントラッキング属性もリンクとフォームに追加しますが、問題はリマーケティング用の変換スクリプトが機能していないことです。Javascriptエラーはありませんが、私のリマーケティングリストに表示されている人もいません。数分ごとに約50回サイトにアクセスするので、そこにいるはずです...

必死に解決策を探しています。

誰かから聞いてみたい

デイブ

4

1 に答える 1

0

ダヴジー

$H(domains).eachまず、 jQuery 関数として認識できないため、使用している jQuery のバージョンを教えてください。$HMootools には関数がありますが、 jQuery にはありません

jQuery オブジェクトを反復処理する場合は、使用する必要があります

$.each(your_array, function(index, value){}

(これは 59 行目のビットにも適用されます - $(\"a[href*='\"+val+\"']\").each)

第二に、コードにエントリがある場合、IE は失敗しconsole.logます。これらは開発環境でのみ使用してください....

それが役立つことを願っています。

トウソン

于 2012-05-12T20:00:17.853 に答える