@@ -86,22 +86,7 @@ public function generate(string $storeId = null): array
8686 ],
8787 'tag ' => $ isAnalyticsEnabled ? $ this ->generateTags ($ accountId , $ containerId , $ timestamp , $ storeId ) : [],
8888 'trigger ' => $ isAnalyticsEnabled ? $ this ->generateTriggers ($ accountId , $ containerId , $ timestamp ) : [],
89- 'variable ' => [
90- [
91- 'accountId ' => $ accountId ,
92- 'containerId ' => $ containerId ,
93- 'variableId ' => '692 ' ,
94- 'name ' => 'Magefan GA4 - Measurement ID ' ,
95- 'type ' => 'c ' ,
96- 'parameter ' => [
97- [
98- 'type ' => 'TEMPLATE ' ,
99- 'key ' => 'value ' ,
100- 'value ' => $ this ->config ->getMeasurementId ($ storeId )
101- ],
102- ]
103- ]
104- ],
89+ 'variable ' => $ isAnalyticsEnabled ? $ this ->generateVariable ($ accountId , $ containerId , $ timestamp , $ storeId ) : [],
10590 'builtInVariable ' => $ isAnalyticsEnabled ? [
10691 [
10792 'accountId ' => $ accountId ,
@@ -282,6 +267,11 @@ private function generateTags(
282267 'type ' => 'TEMPLATE ' ,
283268 'key ' => 'measurementIdOverride ' ,
284269 'value ' => '{{Magefan GA4 - Measurement ID}} '
270+ ],
271+ [
272+ "type " => "TEMPLATE " ,
273+ "key " => "eventSettingsVariable " ,
274+ "value " => "{{Magefan GA4 - User ID}} "
285275 ]
286276 ],
287277 'fingerprint ' => $ timestamp ,
@@ -298,4 +288,66 @@ private function generateTags(
298288 ]
299289 ];
300290 }
291+
292+ /**
293+ * @param string $accountId
294+ * @param string $containerId
295+ * @param string $timestamp
296+ * @param string|null $storeId
297+ * @return array[]
298+ */
299+ private function generateVariable (
300+ string $ accountId ,
301+ string $ containerId ,
302+ string $ timestamp ,
303+ string $ storeId = null
304+ ): array {
305+ return [
306+ [
307+ 'accountId ' => $ accountId ,
308+ 'containerId ' => $ containerId ,
309+ 'variableId ' => '692 ' ,
310+ 'name ' => 'Magefan GA4 - Measurement ID ' ,
311+ 'type ' => 'c ' ,
312+ 'parameter ' => [
313+ [
314+ 'type ' => 'TEMPLATE ' ,
315+ 'key ' => 'value ' ,
316+ 'value ' => $ this ->config ->getMeasurementId ($ storeId )
317+ ],
318+ ]
319+ ],
320+ [
321+ 'accountId ' => $ accountId ,
322+ 'containerId ' => $ containerId ,
323+ 'variableId ' =>'43 ' ,
324+ 'name ' =>'Magefan GA4 - User ID ' ,
325+ 'type ' =>'gtes ' ,
326+ 'parameter ' =>[
327+ [
328+ 'type ' =>'LIST ' ,
329+ 'key ' =>'eventSettingsTable ' ,
330+ 'list ' =>[
331+ [
332+ 'type ' =>'MAP ' ,
333+ 'map ' =>[
334+ [
335+ 'type ' =>'TEMPLATE ' ,
336+ 'key ' =>'parameter ' ,
337+ 'value ' =>'user_id '
338+ ],
339+ [
340+ 'type ' =>'TEMPLATE ' ,
341+ 'key ' =>'parameterValue ' ,
342+ 'value ' =>'{{Magefan DLV - Customer Email Hash}} '
343+ ]
344+ ]
345+ ]
346+ ]
347+ ]
348+ ],
349+ 'fingerprint ' => $ timestamp
350+ ]
351+ ];
352+ }
301353}
0 commit comments