Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Googleアナリティクスのトラッキング設定機能追加 #5029

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/DoctrineMigrations/Version20210505070358.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210505070358 extends AbstractMigration
{
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("ALTER TABLE dtb_base_info ADD COLUMN tracking_id VARCHAR(255) NULL AFTER point_conversion_rate;");

}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs

}
}
27 changes: 27 additions & 0 deletions src/Eccube/Entity/BaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ class BaseInfo extends \Eccube\Entity\AbstractEntity
*/
private $point_conversion_rate = '1';

/**
* @var string|null
*
* @ORM\Column(name="tracking_id", type="string", length=255, nullable=true)
*/
private $tracking_id;

/**
* @var \Eccube\Entity\Master\Country
*
Expand Down Expand Up @@ -1079,5 +1086,25 @@ public function setPhpPath($php_path)

return $this;
}

/**
* @return null|string
*/
public function getTrackingId()
{
return $this->tracking_id;
}

/**
* @param null|string $tracking_id
*
* @return $this
*/
public function setTrackingId($tracking_id)
{
$this->tracking_id = $tracking_id;

return $this;
}
}
}
9 changes: 9 additions & 0 deletions src/Eccube/Form/Type/Admin/ShopMasterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]),
],
])
->add('tracking_id', TextType::class, [
'required' => false,
'constraints' => [
new Assert\Length([
'max' => $this->eccubeConfig['eccube_stext_len'],
]),
],
'attr' => ['placeholder' => 'UA-XXXXXXXXX-X'],
])
;

$builder->add(
Expand Down
1 change: 1 addition & 0 deletions src/Eccube/Resource/doctrine/import_csv/en/dtb_block.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ id,device_type_id,block_name,file_name,create_date,update_date,use_controller,de
12,10,News,news,2017-03-07 10:14:52,2017-03-07 10:14:52,0,0,block
13,10,Product Search,search_product,2017-03-07 10:14:52,2017-03-07 10:14:52,1,0,block
14,10,Featured,topic,2017-03-07 10:14:52,2017-03-07 10:14:52,0,0,block
"15","10","Tracking Code","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"15","10","Tracking Code","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","block"
"15","10","Tracking Code","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","0","0","block"

カラムが不足しているようですのでご確認お願いします

1 change: 1 addition & 0 deletions src/Eccube/Resource/doctrine/import_csv/ja/dtb_block.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
"12","10","新着情報","news","2017-03-07 10:14:52","2017-03-07 10:14:52","0","0","block"
"13","10","商品検索","search_product","2017-03-07 10:14:52","2017-03-07 10:14:52","1","0","block"
"14","10","トピック","topic","2017-03-07 10:14:52","2017-03-07 10:14:52","0","0","block"
"15","10","トラッキングコード","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"15","10","トラッキングコード","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","block"
"15","10","トラッキングコード","tracking_code","2021-05-05 00:00:00","2021-05-05 00:00:00","0","0","block"

カラムが不足しているようですのでご確認お願いします

2 changes: 2 additions & 0 deletions src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,8 @@ admin.setting.shop.shop.option_point: Point Settings
admin.setting.shop.shop.option_point_enabled: Points
admin.setting.shop.shop.option_point_rate: Point Return Rate
admin.setting.shop.shop.option_point_conversion_rate: Point Conversion Rate
admin.setting.shop.shop.option_google_analytics: Google Analytics
admin.setting.shop.shop.option_tracking_id: Tracking ID

#------------------------------------------------------------------------------------
# Settings : Store Settings : Payment Methods
Expand Down
2 changes: 2 additions & 0 deletions src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,8 @@ admin.setting.shop.shop.option_point: ポイント設定
admin.setting.shop.shop.option_point_enabled: ポイント機能
admin.setting.shop.shop.option_point_rate: ポイント付与率
admin.setting.shop.shop.option_point_conversion_rate: ポイント換算レート
admin.setting.shop.shop.option_google_analytics: Google アナリティクス
admin.setting.shop.shop.option_tracking_id: トラッキングID

#------------------------------------------------------------------------------------
# 設定:店舗設定:支払方法設定
Expand Down
18 changes: 18 additions & 0 deletions src/Eccube/Resource/template/admin/Setting/Shop/shop_master.twig
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,24 @@ file that was distributed with this source code.
</div>
</div>
</div>
<div class="card rounded border-0 mb-4">
<div class="card-header"><span>{{ 'admin.setting.shop.shop.option_google_analytics'|trans }}</span></div>
<div id="ex-shop-point" class="card-body">
<div class="row">
<div class="col-3">
<div class="d-inline-block" data-tooltip="true" data-placement="top"><span>{{ 'admin.setting.shop.shop.option_tracking_id'|trans }}</span></div>
</div>
<div class="col mb-2">
<div class="input-group col-2 pl-0">
<div class="input-group">
{{ form_widget(form.tracking_id) }}
{{ form_errors(form.tracking_id) }}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/Eccube/Resource/template/default/Block/tracking_code.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ BaseInfo.tracking_id }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', {{ BaseInfo.tracking_id }});
</script>
4 changes: 4 additions & 0 deletions src/Eccube/Resource/template/default/default_frame.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ file that was distributed with this source code.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="eccube-csrf-token" content="{{ csrf_token(constant('Eccube\\Common\\Constant::TOKEN_NAME')) }}">

{% if BaseInfo.tracking_id %}
{{ include('Block/tracking_code.twig') }}
{% endif %}
<title>{{ BaseInfo.shop_name }}{% if subtitle is defined and subtitle is not empty %} / {{ subtitle }}{% elseif title is defined and title is not empty %} / {{ title }}{% endif %}</title>
{% if Page.meta_tags is not empty %}
{{ include(template_from_string(Page.meta_tags)) }}
Expand Down